重複の可能性:
Javaで日付を解析するには?
"11-10-10 12:00:00"
文字列をオブジェクトに変換したいのですが、Date
できません。助けてもらえますか?
「Mon Oct 11 00:00:00 IST 2010」という値を持つ Date オブジェクトがあります。
DateFormat newDateFormat = new SimpleDateFormat("dd-MM-yy hh:mm:ss");
String strDate = newDateFormat.format(tempDate);
//**i got strDate as strDate is : 11-10-10 12:00:00**
DateFormat newDateFormat1 = new SimpleDateFormat("dd-MM-yy hh:mm:ss");
try {
tempDate = newDateFormat1.parse(strDate);
// **getting tempDate as - Mon Oct 11 00:00:00 IST 2010**
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}