为什么当年份小于1884年时,它删除了几毫秒?
DateTime start = new DateTime().withYear(1884);
System.out.println(start);
System.out.println(start.minusYears(1));
输出
1884-01-11T08:26:10.234-08:00
1883-01-11T08:26:10.234-07:52:58
编辑1:我不正确。它没有删除1.02秒
DateTime start = new DateTime().withYear(1884);
DateTime other = start.minusYears(1);
long diffMs = start.getMillis() - other.getMillis(); //31536422000
编辑 2:
有趣的是,我被输出混淆了 - (,toString();
-08:00
-07:52:58
)
编辑3:
使用Java Calendar,我没有看到任何差异:
Calendar cal = Calendar.getInstance();
cal.set(start.getYear(),
start.getMonthOfYear(),
start.getDayOfMonth(),
start.getHourOfDay(),
start.getMinuteOfHour(),
start.getSecondOfDay());
System.out.println(cal.getTime());
cal = Calendar.getInstance();
cal.set(start.getYear()- 1,
start.getMonthOfYear(),
start.getDayOfMonth(),
start.getHourOfDay(),
start.getMinuteOfHour(),
start.getSecondOfDay());
System.out.println(cal.getTime());
输出:
Mon Feb 11 18:46:42 PST 1884
Sun Feb 11 18:46:42 PST 1883