@Override public int compareTo(Result<T> tResult) { return timestamp.compareTo(tResult.timestamp); }
public static DateTime min(DateTime dt1, DateTime dt2) { return dt1.compareTo(dt2) < 0 ? dt1 : dt2; }
public static DateTime max(DateTime dt1, DateTime dt2) { return dt1.compareTo(dt2) >= 0 ? dt1 : dt2; }
@Override public int compareTo(Row o) { return timestamp.compareTo(o.getTimestamp()); }
@Override public int compareTo(Row o) { return timestamp.compareTo(o.getTimestamp()); } }
@Override public int compareTo(Row o) { return getTimestamp().compareTo(o.getTimestamp()); } };
@Override public int compare(TaskStuff a, TaskStuff b) { return a.getCreatedDate().compareTo(b.getCreatedDate()); } }.reverse();
@Override public int compare(ScalingEvent s1, ScalingEvent s2) { return s2.getTimestamp().compareTo(s1.getTimestamp()); } }.nullsLast();
@Override public int compare(final ExistingEvent arg0, final ExistingEvent arg1) { return arg0.getEffectiveDate().compareTo(arg1.getEffectiveDate()); } });
private static Iterable<Interval> splitInterval(Interval interval, Period period) { if (interval.getEndMillis() == interval.getStartMillis()) { return Collections.singletonList(interval); } List<Interval> intervals = new ArrayList<>(); Iterator<Interval> timestamps = new PeriodGranularity(period, null, null).getIterable(interval).iterator(); DateTime start = DateTimes.max(timestamps.next().getStart(), interval.getStart()); while (timestamps.hasNext()) { DateTime end = timestamps.next().getStart(); intervals.add(new Interval(start, end)); start = end; } if (start.compareTo(interval.getEnd()) < 0) { intervals.add(new Interval(start, interval.getEnd())); } return intervals; }
@Override public int compare(Result<Object> r1, Result<Object> r2) { return r1.getTimestamp().compareTo(r2.getTimestamp()); } },
@Override public Void inTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { final SubscriptionEventSqlDao transactional = entitySqlDaoWrapperFactory.become(SubscriptionEventSqlDao.class); createAndRefresh(transactional, new SubscriptionEventModelDao(bcdEvent), context); // Notify the Bus notifyBusOfRequestedChange(entitySqlDaoWrapperFactory, subscription, bcdEvent, SubscriptionBaseTransitionType.BCD_CHANGE, context); final boolean isBusEvent = bcdEvent.getEffectiveDate().compareTo(context.getCreatedDate()) <= 0; recordBusOrFutureNotificationFromTransaction(subscription, bcdEvent, entitySqlDaoWrapperFactory, isBusEvent, 0, catalog, context); return null; } });
@Override public int compare(final SubscriptionBase o1, final SubscriptionBase o2) { if (o1.getCategory() == ProductCategory.BASE) { return -1; } else if (o2.getCategory() == ProductCategory.BASE) { return 1; } else { return ((DefaultSubscriptionBase) o1).getAlignStartDate().compareTo(((DefaultSubscriptionBase) o2).getAlignStartDate()); } } };
@Test(groups = "fast") public void testComputeUTCDateTimeFromLocalDateC() { final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTimeC); final DateTimeZone timeZone = DateTimeZone.forOffsetHours(8); refreshCallContext(effectiveDateTime, timeZone); final LocalDate endDate = new LocalDate(2013, 01, 20); final DateTime endDateTimeInUTC = internalCallContext.toUTCDateTime(endDate); assertTrue(endDateTimeInUTC.compareTo(effectiveDateTime.plusYears(1)) == 0); }
@Test(groups = "fast") public void testComputeUTCDateTimeFromLocalDate3() { final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTime3); final DateTimeZone timeZone = DateTimeZone.forOffsetHours(-8); refreshCallContext(effectiveDateTime, timeZone); final LocalDate endDate = new LocalDate(2013, 01, 20); final DateTime endDateTimeInUTC = internalCallContext.toUTCDateTime(endDate); assertTrue(endDateTimeInUTC.compareTo(effectiveDateTime.plusYears(1)) == 0); }
@Test(groups = "fast") public void testComputeUTCDateTimeFromLocalDateB() { final DateTime effectiveDateTime = DATE_TIME_FORMATTER.parseDateTime(effectiveDateTimeB); final DateTimeZone timeZone = DateTimeZone.forOffsetHours(8); refreshCallContext(effectiveDateTime, timeZone); final LocalDate endDate = new LocalDate(2013, 01, 21); final DateTime endDateTimeInUTC = internalCallContext.toUTCDateTime(endDate); assertTrue(endDateTimeInUTC.compareTo(effectiveDateTime.plusYears(1)) == 0); }
@Override public int compare(DataSegment lhs, DataSegment rhs) { int retVal; DateTime lhsMonth = Granularities.MONTH.bucketStart(lhs.getInterval().getStart()); DateTime rhsMonth = Granularities.MONTH.bucketStart(rhs.getInterval().getStart()); retVal = lhsMonth.compareTo(rhsMonth); if (retVal != 0) { return retVal; } return lhs.compareTo(rhs); } };
private void insertOverdueCheckAndVerifyQueueContent(final Account account, final int nbDaysInFuture, final int expectedNbDaysInFuture) throws IOException { final DateTime futureNotificationTime = testReferenceTime.plusDays(nbDaysInFuture); final OverdueCheckNotificationKey notificationKey = new OverdueCheckNotificationKey(account.getId()); checkPoster.insertOverdueNotification(account.getId(), futureNotificationTime, OverdueCheckNotifier.OVERDUE_CHECK_NOTIFIER_QUEUE, notificationKey, internalCallContext); final List<NotificationEventWithMetadata<OverdueCheckNotificationKey>> notificationsForKey = getNotificationsForOverdueable(account); Assert.assertEquals(notificationsForKey.size(), 1); final NotificationEventWithMetadata nm = notificationsForKey.get(0); Assert.assertEquals(nm.getEvent(), notificationKey); Assert.assertEquals(nm.getEffectiveDate().compareTo(testReferenceTime.plusDays(expectedNbDaysInFuture)), 0); }
@Test(groups = "slow", enabled = false) public void testWithGMTPlus8() throws SQLException { final LocalDate date1_1 = new LocalDate(2014, 10, 1, GregorianChronology.getInstance(DATE_TZ_PLUS_8_GMT)); // We chose a time such that it moves to next day final DateTime date2_1 = new DateTime(2014, 10, 1, 22, 48, 56, DATE_TZ_PLUS_8_GMT); insertData(date1_1, date2_1, date2_1); final FullOfDates result = readData(); assertEquals(result.getDate1().compareTo(date1_1), 0); assertEquals(result.getDate2().compareTo(date2_1), 0); assertEquals(result.getDate2().getZone().toString(), "UTC"); }
@Test(groups = "slow", enabled = false) public void testWithGMTMinus20() throws SQLException { final LocalDate date1_1 = new LocalDate(2014, 10, 1, GregorianChronology.getInstance(DATE_TZ_MINUS_20_GMT)); // We chose a time such that it moves to next day final DateTime date2_1 = new DateTime(2014, 10, 1, 16, 48, 56, DATE_TZ_MINUS_20_GMT); insertData(date1_1, date2_1, date2_1); final FullOfDates result = readData(); assertEquals(result.getDate1().compareTo(date1_1), 0); assertEquals(result.getDate2().compareTo(date2_1), 0); assertEquals(result.getDate2().getZone().toString(), "UTC"); }