为什么解析带有 weekyear return 的日期是错误的年份?
Why does parsing a date with weekyear return the wrong year?
DateTime time=DateTimeFormat.forPattern("yyyy-ww").parseDateTime("2013-01");
其中 DateTimeFormat
是 org.joda.time.format.DateTimeFormat
。
当我执行上面的时候,时间变成了2013-12-30T00:00:00.000
我究竟做错了什么?这是一个错误吗?我预计这是 2013 年的第一周,而不是最后一周。
参见 here。
w
,weekyear 中的星期,模式字母应与 x
,weekyear 一起使用。来自 javadoc of DateTimeFormat
x weekyear year 1996
w week of weekyear number 27
将模式更改为
DateTimeFormat.forPattern("xxxx-ww")
你将解析为
2012-12-31T00:00:00.000-08:00
根据您的Locale
,2013 年的第一周从 2012 年开始。
DateTime time=DateTimeFormat.forPattern("yyyy-ww").parseDateTime("2013-01");
其中 DateTimeFormat
是 org.joda.time.format.DateTimeFormat
。
当我执行上面的时候,时间变成了2013-12-30T00:00:00.000
我究竟做错了什么?这是一个错误吗?我预计这是 2013 年的第一周,而不是最后一周。
参见 here。
w
,weekyear 中的星期,模式字母应与 x
,weekyear 一起使用。来自 javadoc of DateTimeFormat
x weekyear year 1996
w week of weekyear number 27
将模式更改为
DateTimeFormat.forPattern("xxxx-ww")
你将解析为
2012-12-31T00:00:00.000-08:00
根据您的Locale
,2013 年的第一周从 2012 年开始。