2014-10-09 89 views
1

Joda是否錯誤地解析ISO 8601日期時間字符串?JodaTime是否錯誤地解析了這個日期時間?

DateTimeFormatter f = DateTimeFormat.forPattern("EEE MMM ee kk:mm:ss z y").withZone(DateTimeZone.UTC).withLocale(Locale.US);  
DateTimeFormatter dtf = ISODateTimeFormat.dateTimeNoMillis(); 
dt = dtf.parseDateTime("2015-04-01T11:40:59Z"); 
System.out.println(f.print(dt)); 

此輸出週三四月 11時40分59秒UTC 2015年,但注意到指定四月

+1

'ee'是星期幾,是你期待'dd'這意味着該月的一天嗎? http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html – 2014-10-09 17:06:13

回答

4

e輸入字符串爲的星期幾。您正在尋找d,這是的一天:

DateTimeFormatter f = DateTimeFormat.forPattern("EEE MMM dd kk:mm:ss z y").withZone(DateTimeZone.UTC).withLocale(Locale.US);  
+0

哎呀,謝謝... – 2014-10-09 18:20:32