4
我想解析一个字符串到日期,但输出看起来不正确: 下面是我的代码。Java - SimpleDateFormat解析12:19:00至00:19:00
public static void main(String[] args){
Date startDate = new Date();
DateFormat formatter = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
try {
startDate = (Date) formatter.parse("07.10.2012 12:19:24");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Formatted Date " + startDate.toString());
}
程序的输出:
格式的日期太阳07年10月:19:24 IST 2012
预期输出:
格式的日期太阳07年10月:19:24 IST 2012
谢谢! HH工作。 –