Interface TimeFrame
Belongs to a TimeFrameSet.
The default set is TimeFrames.CORE;
to create custom time frame sets, call TimeFrameSet.builder().
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanRollUpTo(TimeFrame toFrame) Whether this frame can roll up totoFrame.default intReturns a date where this time frame is at the start of a cycle.frameSet()Returns the time frame set that this frame belongs to.default intReturns a month number where this time frame is at the start of a cycle.name()Name of this time frame.@Nullable org.apache.commons.math3.fraction.BigFractionIf this time frame has units in common with another time frame, returns the number of this time frame in one of that time frame.default longReturns a timestamp where this time frame is at the start of a cycle.default @Nullable org.apache.calcite.avatica.util.TimeUnitunit()Returns the built-in unit of this frame, or null if it does not correspond to a built-in unit.
-
Method Details
-
frameSet
TimeFrameSet frameSet()Returns the time frame set that this frame belongs to. -
name
String name()Name of this time frame.A time frame based on a built-in Avatica
TimeUnitwill have the same name.- See Also:
-
per
If this time frame has units in common with another time frame, returns the number of this time frame in one of that time frame.For example,
MONTH.per(YEAR)returns 12;YEAR.per(MONTH)returns 1 / 12. -
dateEpoch
default int dateEpoch()Returns a date where this time frame is at the start of a cycle.For example, the
WEEKtime frame starts on a Monday, and1970-01-05was a Monday, and the date1970-01-05is represented as integer 5, so for theWEEKtime frame this method returns 5. But it would also be valid to return the date value of1900/01/01, which was also a Monday. Because we know that a week is 7 days, we can compute every other point at which a week advances. -
timestampEpoch
default long timestampEpoch()Returns a timestamp where this time frame is at the start of a cycle.- See Also:
-
monthEpoch
default int monthEpoch()Returns a month number where this time frame is at the start of a cycle.- See Also:
-
canRollUpTo
Whether this frame can roll up totoFrame.Examples:
SECONDcan roll up toMINUTE,HOUR,DAY,WEEK,MONTH,MILLENNIUM;SECONDcannot roll up toMILLISECOND(because it is finer grained);WEEKcannot roll up toMONTH,YEAR,MILLENNIUM(because weeks cross month boundaries).
If two time frames have the same core, and one is an integer simple multiple of another, and they have the same offset, then they can roll up. For example, suppose that
MINUTE15andHOUR3are both based onSECOND;MINUTE15is 15 * 60 seconds andHOUR3is 3 * 60 * 60 seconds; therefore oneHOUR3interval equals twelveMINUTE15intervals. They have the same offset (both start at1970-01-01 00:00:00) and thereforeMINUTE15can roll up toHOUR3.Even if two frames are not multiples, if they are aligned then they can roll up.
MONTHandDAYare an example. For more about alignment, seeTimeFrameSet.Builder.addRollup(String, String). -
unit
default @Nullable org.apache.calcite.avatica.util.TimeUnit unit()Returns the built-in unit of this frame, or null if it does not correspond to a built-in unit.
-