您好,我有这段代码摘录:
end = new DateTime(mergeToDateTime(this.endDate, this.empEndTime));
Duration extraTime = new Duration(this.preTime.getTime()); //add the first 30 mins
extraTime = extraTime.plus(new Duration(this.postTime.getTime())); //add the second 30 mins
end = end.plus(extraTime); // extraTime = -3600?
当我查看调试器时,我的持续时间总是为负数。我不知道为什么会这样,即使根据API,可以从long类型创建持续时间,因此getTime()。(preTime和postTime是java.sql.Time类型)