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工作。 –