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 TableasDbDateTime(Table source, MatchPair matchPair)Convert the specified column in the table to aDBDateTimecolumn.static TableasDbDateTime(Table source, String column)Convert the specified column in the table to aDBDateTimecolumn.static TableasEpochNanos(Table source, MatchPair matchPair)Convert the specified column in the table to alongcolumn of nanos since epoch.*static TableasEpochNanos(Table source, String column)Convert the specified column in the table to alongcolumn of nanos since epoch.static TableasInstant(Table source, MatchPair matchPair)Convert the specified column in the table to anInstantcolumn.static TableasInstant(Table source, String column)Convert the specified column in the table to anInstantcolumn.static TableasLocalDate(Table source, MatchPair matchPair, String zone)Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(Table source, MatchPair matchPair, ZoneId zone)Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(Table source, String column, String zone)Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(Table source, String column, ZoneId zone)Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalTime(Table source, MatchPair matchPair, String zone)Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(Table source, MatchPair matchPair, ZoneId zone)Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(Table source, String column, String zone)Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(Table source, String column, ZoneId zone)Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasZonedDateTime(Table source, MatchPair matchPair, String zone)Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(Table source, MatchPair matchPair, ZoneId zone)Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(Table source, String column, String zone)Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(Table source, String column, ZoneId zone)Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static booleanisTimeType(Class<?> type)Check if the supplied type is one of the supported time types.static booleanrequiresZone(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 aZonedDateTimecolumn 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, inMatchPairformatzone- The time zone to use.- Returns:
- the
Tablewith 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 aZonedDateTimecolumn 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- TheMatchPairof columnszone- The time zone to use.- Returns:
- the
Tablewith 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 aZonedDateTimecolumn at the specified time zone.- Parameters:
source- The source tablecolumn- The column to convert, inMatchPairformatzone- The time zone to use.- Returns:
- the
Tablewith 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 aZonedDateTimecolumn at the specified time zone.- Parameters:
source- The source tablematchPair- TheMatchPairof columnszone- The time zone to use.- Returns:
- the
Tablewith 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 aLocalTimecolumn 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 aLocalTimecolumn 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 aLocalTimecolumn 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 aLocalTimecolumn 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 aLocalDatecolumn 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 aLocalDatecolumn 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 aLocalDatecolumn 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 aLocalDatecolumn at the specified time zone. -
asInstant
Convert the specified column in the table to anInstantcolumn. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn" -
asInstant
Convert the specified column in the table to anInstantcolumn. -
asDbDateTime
Convert the specified column in the table to aDBDateTimecolumn. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"- Parameters:
source- The source tablecolumn- The column to convert, inMatchPairformat- Returns:
- the
Tablewith the specified column converted toDBDateTime.
-
asDbDateTime
Convert the specified column in the table to aDBDateTimecolumn.- Parameters:
source- The source tablematchPair- TheMatchPairof columns- Returns:
- the
Tablewith the specified column converted toDBDateTime.
-
asEpochNanos
Convert the specified column in the table to alongcolumn 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 alongcolumn 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
-