Class TimeDuration

    • Field Detail

      • monthDuration

        public final int monthDuration
      • nonMonthDuration

        public final long nonMonthDuration
    • Constructor Detail

      • TimeDuration

        public TimeDuration​(int monthDuration,
                            long nonMonthDuration)
    • Method Detail

      • containsMonth

        public boolean containsMonth()
      • getTotalDuration

        public long getTotalDuration​(TimeUnit currPrecision)
        Convert monthDuration to current precision duration, then add currPrecisionDuration field. Think month as 30 days.
        Returns:
        the total duration of this timeDuration in current precision
      • getMaxTotalDuration

        public long getMaxTotalDuration​(TimeUnit currPrecision)
        Think month as 31 days.
      • getMinTotalDuration

        public long getMinTotalDuration​(TimeUnit currPrecision)
        Think month as 28 days.
      • serialize

        public void serialize​(ByteBuffer buffer)
      • getConsecutiveTimesIntervalByMonth

        public static long[] getConsecutiveTimesIntervalByMonth​(long startTime,
                                                                TimeDuration duration,
                                                                int length,
                                                                TimeZone timeZone,
                                                                TimeUnit currPrecision)
        Get a series of time which duration contains month.
      • calcPositiveIntervalByMonth

        public static long calcPositiveIntervalByMonth​(long startTime,
                                                       TimeDuration duration,
                                                       long times,
                                                       TimeZone timeZone,
                                                       TimeUnit currPrecision)
        Add several time durations contains natural months based on the startTime and avoid edge cases, ie 2/28
        Parameters:
        startTime - start time
        duration - one duration
        times - num of duration elapsed
        Returns:
        the time after durations elapsed
      • calcNegativeIntervalByMonth

        public static long calcNegativeIntervalByMonth​(long startTime,
                                                       TimeDuration duration,
                                                       TimeZone timeZone,
                                                       TimeUnit currPrecision)
        subtract time duration contains natural months based on the startTime
        Parameters:
        startTime - start time
        duration - the duration
        Returns:
        the time before duration
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object