本文整理汇总了Java中org.ofbiz.base.util.TimeDuration.ZeroTimeDuration方法的典型用法代码示例。如果您正苦于以下问题:Java TimeDuration.ZeroTimeDuration方法的具体用法?Java TimeDuration.ZeroTimeDuration怎么用?Java TimeDuration.ZeroTimeDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ofbiz.base.util.TimeDuration
的用法示例。
在下文中一共展示了TimeDuration.ZeroTimeDuration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDuration
import org.ofbiz.base.util.TimeDuration; //导入方法依赖的package包/类
public void testDuration() throws Exception {
Calendar now = Calendar.getInstance();
TimeDuration zeroDuration = TimeDuration.ZeroTimeDuration;
assertFalse("zero equals null", zeroDuration.equals(null));
Calendar newTime = (Calendar) now.clone();
zeroDuration.addToCalendar(newTime);
assertEquals("zero same calendar", now, newTime);
assertDurationFields("zero(same zero calendar)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", new TimeDuration(zero, zero), false, true);
assertDurationFields("zero(same now calendar)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", new TimeDuration(now, now), false, true);
assertDurationFields("zero(empty parse)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", TimeDuration.parseDuration(""), false, true);
assertDurationFields("zero(zero parse)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", TimeDuration.parseDuration("0:0:0:0:0:0:0"), false, true);
assertDurationFields("zero(from null number)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", TimeDuration.fromNumber(null), false, true);
assertDurationFields("zero(from null number)", 0, 0, 0, 0, 0, 0, 0, "0:0:0:0:0:0:0", TimeDuration.fromNumber(null), false, true);
assertDuration("millisecond", 0, 0, 0, 0, 0, 0, 1);
assertDuration("second", 0, 0 ,0 ,0, 0, 1, 0);
assertDuration("minute", 0, 0, 0, 0, 1, 0, 0);
assertDuration("hour", 0, 0, 0, 1, 0, 0, 0);
assertDuration("day", 0, 0, 1, 0, 0, 0, 0);
assertDuration("month", 0, 1, 0, 0, 0, 0, 0);
assertDuration("year", 1, 0, 0, 0, 0, 0, 0);
Calendar start = new com.ibm.icu.util.GregorianCalendar(1967, 1, 1, 0, 0, 0);
start.set(Calendar.MILLISECOND, 0);
Calendar end = (Calendar) start.clone();
end.add(Calendar.MILLISECOND, 1);
end.add(Calendar.SECOND, 1);
end.add(Calendar.MINUTE, 1);
end.add(Calendar.HOUR_OF_DAY, 1);
end.add(Calendar.DAY_OF_MONTH, 1);
end.add(Calendar.MONTH, 1);
end.add(Calendar.YEAR, 1);
assertDurationFields("pre-epoch elapsed time", 1, 1, 1, 1, 1, 1, 1, "1:1:1:1:1:1:1", new TimeDuration(start, end), false, false);
}