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 TypeMethodDescriptionboolean
canRollUpTo
(TimeFrame toFrame) Whether this frame can roll up totoFrame
.default int
Returns 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 int
Returns 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.BigFraction
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.default long
Returns a timestamp where this time frame is at the start of a cycle.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.
-
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
TimeUnit
will 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
WEEK
time frame starts on a Monday, and1970-01-05
was a Monday, and the date1970-01-05
is represented as integer 5, so for theWEEK
time 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:
SECOND
can roll up toMINUTE
,HOUR
,DAY
,WEEK
,MONTH
,MILLENNIUM
;SECOND
cannot roll up toMILLISECOND
(because it is finer grained);WEEK
cannot 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
MINUTE15
andHOUR3
are both based onSECOND
;MINUTE15
is 15 * 60 seconds andHOUR3
is 3 * 60 * 60 seconds; therefore oneHOUR3
interval equals twelveMINUTE15
intervals. They have the same offset (both start at1970-01-01 00:00:00
) and thereforeMINUTE15
can roll up toHOUR3
.Even if two frames are not multiples, if they are aligned then they can roll up.
MONTH
andDAY
are 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.
-