Package org.apache.iotdb.tsfile.utils
Class TimeDuration
- java.lang.Object
-
- org.apache.iotdb.tsfile.utils.TimeDuration
-
- All Implemented Interfaces:
Serializable
public class TimeDuration extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description intmonthDurationlongnonMonthDuration
-
Constructor Summary
Constructors Constructor Description TimeDuration(int monthDuration, long nonMonthDuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longcalcNegativeIntervalByMonth(long startTime, TimeDuration duration, TimeZone timeZone, TimeUnit currPrecision)subtract time duration contains natural months based on the startTimestatic longcalcPositiveIntervalByMonth(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/28booleancontainsMonth()static TimeDurationdeserialize(ByteBuffer buffer)booleanequals(Object o)static long[]getConsecutiveTimesIntervalByMonth(long startTime, TimeDuration duration, int length, TimeZone timeZone, TimeUnit currPrecision)Get a series of time which duration contains month.longgetMaxTotalDuration(TimeUnit currPrecision)Think month as 31 days.longgetMinTotalDuration(TimeUnit currPrecision)Think month as 28 days.longgetTotalDuration(TimeUnit currPrecision)Convert monthDuration to current precision duration, then add currPrecisionDuration field.inthashCode()voidserialize(DataOutputStream stream)voidserialize(ByteBuffer buffer)
-
-
-
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)
-
serialize
public void serialize(DataOutputStream stream) throws IOException
- Throws:
IOException
-
deserialize
public static TimeDuration deserialize(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 timeduration- one durationtimes- 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 timeduration- the duration- Returns:
- the time before duration
-
-