@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Time && arg2 instanceof Time) { return Time.max((Time) arg1, (Time) arg2); } else if (arg1 instanceof Duration && arg2 instanceof Duration) { return Duration.max((Duration) arg1, (Duration) arg2); } else { throw new UnsupportedOperationException("MAX not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Time && arg2 instanceof Time) { return Time.max((Time) arg1, (Time) arg2); } else if (arg1 instanceof Duration && arg2 instanceof Duration) { return Duration.max((Duration) arg1, (Duration) arg2); } else { throw new UnsupportedOperationException("MAX not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Time && arg2 instanceof Time) { return Time.max((Time) arg1, (Time) arg2); } else if (arg1 instanceof Duration && arg2 instanceof Duration) { return Duration.max((Duration) arg1, (Duration) arg2); } else { throw new UnsupportedOperationException("MAX not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public static Pair<PartialTime, PartialTime> getCompatible(PartialTime t1, PartialTime t2) { // Incompatible timezones if (t1.dateTimeZone != null && t2.dateTimeZone != null && !t1.dateTimeZone.equals(t2.dateTimeZone)) return null; if (t1.isCompatible(t2)) return Pair.makePair(t1,t2); if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity == null) { if (t1.uncertaintyGranularity.compareTo(t2.getDuration()) > 0) { // Drop the uncertain fields from t1 Duration d = t1.uncertaintyGranularity; PartialTime t1b = t1.reduceGranularityTo(d); if (t1b.isCompatible(t2)) return Pair.makePair(t1b,t2); } } else if (t1.uncertaintyGranularity == null && t2.uncertaintyGranularity != null) { if (t2.uncertaintyGranularity.compareTo(t1.getDuration()) > 0) { // Drop the uncertain fields from t2 Duration d = t2.uncertaintyGranularity; PartialTime t2b = t2.reduceGranularityTo(d); if (t1.isCompatible(t2b)) return Pair.makePair(t1,t2b); } } else if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity != null) { Duration d1 = Duration.max(t1.uncertaintyGranularity, t2.getDuration()); Duration d2 = Duration.max(t2.uncertaintyGranularity, t1.getDuration()); PartialTime t1b = t1.reduceGranularityTo(d1); PartialTime t2b = t2.reduceGranularityTo(d2); if (t1b.isCompatible(t2b)) return Pair.makePair(t1b,t2b); } return null; }
public static Pair<PartialTime, PartialTime> getCompatible(PartialTime t1, PartialTime t2) { // Incompatible timezones if (t1.dateTimeZone != null && t2.dateTimeZone != null && !t1.dateTimeZone.equals(t2.dateTimeZone)) return null; if (t1.isCompatible(t2)) return Pair.makePair(t1,t2); if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity == null) { if (t1.uncertaintyGranularity.compareTo(t2.getDuration()) > 0) { // Drop the uncertain fields from t1 Duration d = t1.uncertaintyGranularity; PartialTime t1b = t1.reduceGranularityTo(d); if (t1b.isCompatible(t2)) return Pair.makePair(t1b,t2); } } else if (t1.uncertaintyGranularity == null && t2.uncertaintyGranularity != null) { if (t2.uncertaintyGranularity.compareTo(t1.getDuration()) > 0) { // Drop the uncertain fields from t2 Duration d = t2.uncertaintyGranularity; PartialTime t2b = t2.reduceGranularityTo(d); if (t1.isCompatible(t2b)) return Pair.makePair(t1,t2b); } } else if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity != null) { Duration d1 = Duration.max(t1.uncertaintyGranularity, t2.getDuration()); Duration d2 = Duration.max(t2.uncertaintyGranularity, t1.getDuration()); PartialTime t1b = t1.reduceGranularityTo(d1); PartialTime t2b = t2.reduceGranularityTo(d2); if (t1b.isCompatible(t2b)) return Pair.makePair(t1b,t2b); } return null; }
public static Duration difference(Time t1, Time t2) { // TODO: Difference does not work between days of the week // Get duration from this t1 to t2 if (t1 == null || t2 == null) return null; Instant i1 = t1.getJodaTimeInstant(); Instant i2 = t2.getJodaTimeInstant(); if (i1 == null || i2 == null) return null; Duration d = new DurationWithMillis(i2.getMillis() - i1.getMillis()); Duration g1 = t1.getGranularity(); Duration g2 = t2.getGranularity(); Duration g = Duration.max(g1, g2); if (g != null) { Period p = g.getJodaTimePeriod(); p = p.normalizedStandard(); Period p2 = JodaTimeUtils.discardMoreSpecificFields(d.getJodaTimePeriod(), p.getFieldType(p.size() - 1), i1.getChronology()); return new DurationWithFields(p2); } else { return d; } }
public static Duration difference(Time t1, Time t2) { // TODO: Difference does not work between days of the week // Get duration from this t1 to t2 if (t1 == null || t2 == null) return null; Instant i1 = t1.getJodaTimeInstant(); Instant i2 = t2.getJodaTimeInstant(); if (i1 == null || i2 == null) return null; Duration d = new DurationWithMillis(i2.getMillis() - i1.getMillis()); Duration g1 = t1.getGranularity(); Duration g2 = t2.getGranularity(); Duration g = Duration.max(g1, g2); if (g != null) { Period p = g.getJodaTimePeriod(); p = p.normalizedStandard(); Period p2 = JodaTimeUtils.discardMoreSpecificFields(d.getJodaTimePeriod(), p.getFieldType(p.size() - 1), i1.getChronology()); return new DurationWithFields(p2); } else { return d; } }
public static Duration difference(Time t1, Time t2) { // Get duration from this t1 to t2 if (t1 == null || t2 == null) return null; Instant i1 = t1.getJodaTimeInstant(); Instant i2 = t2.getJodaTimeInstant(); if (i1 == null || i2 == null) return null; Duration d = new DurationWithMillis(i2.getMillis() - i1.getMillis()); Duration g1 = t1.getGranularity(); Duration g2 = t2.getGranularity(); Duration g = Duration.max(g1, g2); if (g != null) { Period p = g.getJodaTimePeriod(); p = p.normalizedStandard(); Period p2 = JodaTimeUtils.discardMoreSpecificFields(d.getJodaTimePeriod(), p.getFieldType(p.size() - 1), i1.getChronology()); return new DurationWithFields(p2); } else { return d; } }
@Override public Temporal apply(Temporal arg1, Temporal arg2, int flags) { if (arg1 == null) { return arg2; } if (arg2 == null) { return arg1; } if (arg1 instanceof Time && arg2 instanceof Time) { return Time.max((Time) arg1, (Time) arg2); } else if (arg1 instanceof Duration && arg2 instanceof Duration) { return Duration.max((Duration) arg1, (Duration) arg2); } else { throw new UnsupportedOperationException("MAX not implemented for arg1=" + arg1.getClass() + ", arg2=" + arg2.getClass()); } } },
public static Pair<PartialTime, PartialTime> getCompatible(PartialTime t1, PartialTime t2) { // Incompatible timezones if (t1.dateTimeZone != null && t2.dateTimeZone != null && !t1.dateTimeZone.equals(t2.dateTimeZone)) return null; if (t1.isCompatible(t2)) return Pair.makePair(t1,t2); if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity == null) { if (t1.uncertaintyGranularity.compareTo(t2.getDuration()) > 0) { // Drop the uncertain fields from t1 Duration d = t1.uncertaintyGranularity; PartialTime t1b = t1.reduceGranularityTo(d); if (t1b.isCompatible(t2)) return Pair.makePair(t1b,t2); } } else if (t1.uncertaintyGranularity == null && t2.uncertaintyGranularity != null) { if (t2.uncertaintyGranularity.compareTo(t1.getDuration()) > 0) { // Drop the uncertain fields from t2 Duration d = t2.uncertaintyGranularity; PartialTime t2b = t2.reduceGranularityTo(d); if (t1.isCompatible(t2b)) return Pair.makePair(t1,t2b); } } else if (t1.uncertaintyGranularity != null && t2.uncertaintyGranularity != null) { Duration d1 = Duration.max(t1.uncertaintyGranularity, t2.getDuration()); Duration d2 = Duration.max(t2.uncertaintyGranularity, t1.getDuration()); PartialTime t1b = t1.reduceGranularityTo(d1); PartialTime t2b = t2.reduceGranularityTo(d2); if (t1b.isCompatible(t2b)) return Pair.makePair(t1b,t2b); } return null; }
public static Duration difference(Time t1, Time t2) { // TODO: Difference does not work between days of the week // Get duration from this t1 to t2 if (t1 == null || t2 == null) return null; Instant i1 = t1.getJodaTimeInstant(); Instant i2 = t2.getJodaTimeInstant(); if (i1 == null || i2 == null) return null; Duration d = new DurationWithMillis(i2.getMillis() - i1.getMillis()); Duration g1 = t1.getGranularity(); Duration g2 = t2.getGranularity(); Duration g = Duration.max(g1, g2); if (g != null) { Period p = g.getJodaTimePeriod(); p = p.normalizedStandard(); Period p2 = JodaTimeUtils.discardMoreSpecificFields(d.getJodaTimePeriod(), p.getFieldType(p.size() - 1), i1.getChronology()); return new DurationWithFields(p2); } else { return d; } }