【发布时间】:2011-06-02 20:46:16
【问题描述】:
我想将字符串"11-10-10 12:00:00" 转换为Date 对象,但我不能这样做。你能帮帮我吗?
我有一个 Date 对象,其值为“Mon Oct 11 00:00:00 IST 2010”
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();
}
【问题讨论】:
-
什么语言 - 看起来像 C#。这也被问过很多次了。查看“相关”下的问题 ->
标签: java date-format simpledateformat