List of usage examples for org.joda.time DateTimeUtils getInstantChronology
public static final Chronology getInstantChronology(ReadableInstant instant)
From source file:org.apereo.portal.events.aggr.AggregationInterval.java
License:Apache License
/** * Determine the number of intervals between the start and end dates * * @param start Start, inclusive/*from ww w .j a va 2s. c o m*/ * @param end End, exclusive * @return Number of intervals between start and end */ public int determineIntervalsBetween(ReadableInstant start, ReadableInstant end) { if (!this.isSupportsDetermination()) { throw new IllegalArgumentException("Cannot compute intervals between for " + this + " please use " + AggregationIntervalHelper.class); } final DateTimeFieldType dtft; final double ratio; switch (this) { case FIVE_MINUTE: { dtft = MINUTE.getDateTimeFieldType(); ratio = 5; break; } default: { dtft = dateTimeFieldType; ratio = 1; } } final DurationFieldType durationType = dtft.getDurationType(); final Chronology chrono = DateTimeUtils.getInstantChronology(start); return (int) Math .round(durationType.getField(chrono).getDifference(end.getMillis(), start.getMillis()) / ratio); }