/** The difference between 2 durations. Order is unimportant. */
 @MethodContract(
     pre = {@Expression("d1 != null"), @Expression("d2 != null")},
     post = {
       @Expression("result != null"),
       @Expression("result.asMillisecond() == Math.abs(d1.asMillisecond() - d2.asMillisecond())")
     })
 public static Duration delta(Duration d1, Duration d2) {
   assert preArgumentNotNull(d1, "d1");
   assert preArgumentNotNull(d2, "d2");
   long result = Math.abs(d1.asMillisecond() - d2.asMillisecond());
   return new Duration(result, MILLISECOND);
 }
 /** The sum of the durations in {@code d}. */
 @MethodContract(
     pre = {
       @Expression("for (int i = 0 .. d.length) {d[i] != null}"),
       @Expression("sum (Duration aD : d) {d.asMillisecond()} <= Long.MAX_VALUE")
     },
     post = {
       @Expression("result != null"),
       @Expression("d.length == 0 ? result.asMillisecond() == 0"),
       @Expression(
           "d.length != 0 ? result.asMillisecond() == sum(d[1..d.length]) + d[0].asMillisecond()")
     })
 public static Duration sum(Duration... d) {
   preSum(d);
   long result = 0;
   for (Duration aD : d) {
     result += aD.asMillisecond();
   }
   return new Duration(result, MILLISECOND);
 }