约达时间分钟,我有这个简单的代码:的持续时间或间隔
DateTime date = new DateTime(dateValue);
DateTime currentDate = new DateTime(System.currentTimeMillis());
System.out.println("date: " + date.toString());
System.out.println("currentDate: " + currentDate.toString());
Period period = new Period(currentDate, date);
System.out.println("PERIOD MINUTES: " + period.getMinutes());
System.out.println("PERIOD DAYS: " + period.getDays());
Duration duration = new Duration(currentDate, date);
System.out.println("DURATION MINUTES: " + duration.getStandardMinutes());
System.out.println("DURATION DAYS: " + duration.getStandardDays());
我想简单地找出天的两个随机日期之间的数量和分钟。
这是这段代码的输出:
date: 2012-02-09T00:00:00.000+02:00
currentDate: 2012-02-09T18:15:40.739+02:00
PERIOD MINUTES: -15
PERIOD DAYS: 0
DURATION MINUTES: -1095
DURATION DAYS: 0
我猜,我做错了什么,我看不出有什么。
哦,我从来没有完全明白这一点。我开悟了。 – 2012-02-09 22:46:27
@LouisWasserman:我在将Joda Time移植到.NET时有点特殊,所以我可能比大多数人对它有更好的理解:) – 2012-02-09 22:49:24