Package com.illumon.iris.db.v2.utils
Class TableTimeConversions
java.lang.Object
com.illumon.iris.db.v2.utils.TableTimeConversions
public class TableTimeConversions extends Object
This class contains static methods to support conversions between various time types such as
DBDateTime
, Instant
, ZonedDateTime
, LocalDate
, LocalTime
,
and long
.
For example, lets say that you wanted to select multiple days from a table, but filter them to a specific times of the day.
baseTable = db.i("Market", "Trades") .where("Date > `2021-10-01`") startTime = LocalTime.of(10,30,00) endTime = LocalTime.of(16,30,00) augmented = TimeTableConversions.asLocalTime(baseTable, "LocalTime = Timestamp", "America/New_York")) .where("LocalTime.isAfter(startTime)", "LocalTime.isBefore(endTime)")
-
Constructor Summary
Constructors Constructor Description TableTimeConversions()
-
Method Summary
Modifier and Type Method Description static Table
asDbDateTime(Table source, MatchPair matchPair)
Convert the specified column in the table to aDBDateTime
column.static Table
asDbDateTime(Table source, String column)
Convert the specified column in the table to aDBDateTime
column.static Table
asEpochNanos(Table source, MatchPair matchPair)
Convert the specified column in the table to along
column of nanos since epoch.*static Table
asEpochNanos(Table source, String column)
Convert the specified column in the table to along
column of nanos since epoch.static Table
asInstant(Table source, MatchPair matchPair)
Convert the specified column in the table to anInstant
column.static Table
asInstant(Table source, String column)
Convert the specified column in the table to anInstant
column.static Table
asLocalDate(Table source, MatchPair matchPair, String zone)
Convert the specified column in the table to aLocalDate
column at the specified time zone.static Table
asLocalDate(Table source, MatchPair matchPair, ZoneId zone)
Convert the specified column in the table to aLocalDate
column at the specified time zone.static Table
asLocalDate(Table source, String column, String zone)
Convert the specified column in the table to aLocalDate
column at the specified time zone.static Table
asLocalDate(Table source, String column, ZoneId zone)
Convert the specified column in the table to aLocalDate
column at the specified time zone.static Table
asLocalTime(Table source, MatchPair matchPair, String zone)
Convert the specified column in the table to aLocalTime
column at the specified time zone.static Table
asLocalTime(Table source, MatchPair matchPair, ZoneId zone)
Convert the specified column in the table to aLocalTime
column at the specified time zone.static Table
asLocalTime(Table source, String column, String zone)
Convert the specified column in the table to aLocalTime
column at the specified time zone.static Table
asLocalTime(Table source, String column, ZoneId zone)
Convert the specified column in the table to aLocalTime
column at the specified time zone.static Table
asZonedDateTime(Table source, MatchPair matchPair, String zone)
Convert the specified column in the table to aZonedDateTime
column at the specified time zone.static Table
asZonedDateTime(Table source, MatchPair matchPair, ZoneId zone)
Convert the specified column in the table to aZonedDateTime
column at the specified time zone.static Table
asZonedDateTime(Table source, String column, String zone)
Convert the specified column in the table to aZonedDateTime
column at the specified time zone.static Table
asZonedDateTime(Table source, String column, ZoneId zone)
Convert the specified column in the table to aZonedDateTime
column at the specified time zone.static boolean
isTimeType(Class<?> type)
Check if the supplied type is one of the supported time types.static boolean
requiresZone(Class<?> type)
Check if the supplied time type requires a time zone for construction.
-
Constructor Details
-
TableTimeConversions
public TableTimeConversions()
-
-
Method Details
-
asZonedDateTime
@ScriptApi public static Table asZonedDateTime(@NotNull Table source, @NotNull String column, @NotNull String zone)Convert the specified column in the table to aZonedDateTime
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"- Parameters:
source
- The source tablecolumn
- The column to convert, inMatchPair
formatzone
- The time zone to use.- Returns:
- the
Table
with the specified column converted toZonedDateTime
.
-
asZonedDateTime
@ScriptApi public static Table asZonedDateTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone)Convert the specified column in the table to aZonedDateTime
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"- Parameters:
source
- The source tablematchPair
- TheMatchPair
of columnszone
- The time zone to use.- Returns:
- the
Table
with the specified column converted toZonedDateTime
.
-
asZonedDateTime
@ScriptApi public static Table asZonedDateTime(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone)Convert the specified column in the table to aZonedDateTime
column at the specified time zone.- Parameters:
source
- The source tablecolumn
- The column to convert, inMatchPair
formatzone
- The time zone to use.- Returns:
- the
Table
with the specified column converted toZonedDateTime
.
-
asZonedDateTime
@ScriptApi public static Table asZonedDateTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone)Convert the specified column in the table to aZonedDateTime
column at the specified time zone.- Parameters:
source
- The source tablematchPair
- TheMatchPair
of columnszone
- The time zone to use.- Returns:
- the
Table
with the specified column converted toZonedDateTime
.
-
asLocalTime
@ScriptApi public static Table asLocalTime(@NotNull Table source, @NotNull String column, @NotNull String zone)Convert the specified column in the table to aLocalTime
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asLocalTime
@ScriptApi public static Table asLocalTime(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone)Convert the specified column in the table to aLocalTime
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asLocalTime
@ScriptApi public static Table asLocalTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone)Convert the specified column in the table to aLocalTime
column at the specified time zone. -
asLocalTime
@ScriptApi public static Table asLocalTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone)Convert the specified column in the table to aLocalTime
column at the specified time zone. -
asLocalDate
@ScriptApi public static Table asLocalDate(@NotNull Table source, @NotNull String column, @NotNull String zone)Convert the specified column in the table to aLocalDate
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asLocalDate
@ScriptApi public static Table asLocalDate(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone)Convert the specified column in the table to aLocalDate
column at the specified time zone. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asLocalDate
@ScriptApi public static Table asLocalDate(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone)Convert the specified column in the table to aLocalDate
column at the specified time zone. -
asLocalDate
@ScriptApi public static Table asLocalDate(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone)Convert the specified column in the table to aLocalDate
column at the specified time zone. -
asInstant
Convert the specified column in the table to anInstant
column. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asInstant
Convert the specified column in the table to anInstant
column. -
asDbDateTime
Convert the specified column in the table to aDBDateTime
column. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"- Parameters:
source
- The source tablecolumn
- The column to convert, inMatchPair
format- Returns:
- the
Table
with the specified column converted toDBDateTime
.
-
asDbDateTime
Convert the specified column in the table to aDBDateTime
column.- Parameters:
source
- The source tablematchPair
- TheMatchPair
of columns- Returns:
- the
Table
with the specified column converted toDBDateTime
.
-
asEpochNanos
Convert the specified column in the table to along
column of nanos since epoch. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asEpochNanos
Convert the specified column in the table to along
column of nanos since epoch.* -
isTimeType
Check if the supplied type is one of the supported time types.- Parameters:
type
- the type- Returns:
- true if the type is one of the useable time types
-
requiresZone
Check if the supplied time type requires a time zone for construction.- Parameters:
type
- the type- Returns:
- true if the type requires a timezone
-