[英]Wrong date being displayed when trying to parse a date
當我運行以下代碼時,我得到的輸出為
2016-01-10T06:00:06.000+05:30
但是當我實際上期望月份為06而不是01時。
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
public class Test2 {
public static void main(String[] args) {
String last_notified_date_fromDB_string = "2016-06-10 06:00:06";
DateTimeFormatter formatter = DateTimeFormat.forPattern("YYYY-MM-DD HH:mm:ss");
System.out.println(formatter.parseDateTime(last_notified_date_fromDB_string));
}
}
知道為什么會這樣嗎? 謝謝。
因為D
是一年中的某一天(應為d
)。
由於一年的第十天是一月,因此該月將重置為01
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.