public long periodsElapsed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long diff = end - start; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / CoreConstants.MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / CoreConstants.MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / CoreConstants.MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / CoreConstants.MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / CoreConstants.MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodsElapsed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long diff = end - start; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / CoreConstants.MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / CoreConstants.MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / CoreConstants.MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / CoreConstants.MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / CoreConstants.MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodsElapsed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long diff = end - start; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / CoreConstants.MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / CoreConstants.MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / CoreConstants.MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / CoreConstants.MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / CoreConstants.MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodsElapsed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long diff = end - start; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / CoreConstants.MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / CoreConstants.MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / CoreConstants.MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / CoreConstants.MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / CoreConstants.MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodBarriersCrossed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone()); long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone()); long diff = endFloored - startFloored; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodBarriersCrossed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone()); long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone()); long diff = endFloored - startFloored; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }
public long periodBarriersCrossed(long start, long end) { if (start > end) throw new IllegalArgumentException("Start cannot come before end"); long startFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(start, getTimeZone()); long endFloored = getStartOfCurrentPeriodWithGMTOffsetCorrection(end, getTimeZone()); long diff = endFloored - startFloored; switch (periodicityType) { case TOP_OF_MILLISECOND: return diff; case TOP_OF_SECOND: return diff / MILLIS_IN_ONE_SECOND; case TOP_OF_MINUTE: return diff / MILLIS_IN_ONE_MINUTE; case TOP_OF_HOUR: return (int) diff / MILLIS_IN_ONE_HOUR; case TOP_OF_DAY: return diff / MILLIS_IN_ONE_DAY; case TOP_OF_WEEK: return diff / MILLIS_IN_ONE_WEEK; case TOP_OF_MONTH: return diffInMonths(start, end); default: throw new IllegalStateException("Unknown periodicity type."); } }