0
DateFormat dateFormat = new SimpleDateFormat ("EEE, d MMM Y HH:mm:ss Z", Locale.ENGLISH);

String date = "Mon, 21 Oct 2013 22:21:00 +0400";
dateFormat.format(dateFormat.parse(date)); // returns "Mon, 31 Dec 2013 22:21:00 +0400"

为什么结果字符串与月份和月份日期中的输入日期变量不同?

4

1 回答 1

1

你得到那个输出,因为你使用了错误的格式。您应该使用y(小写) 表示year,而不是Y- 用于表示周年

"EEE, d MMM y HH:mm:ss Z"
于 2013-10-21T19:09:00.027 回答