Class TableTimeConversions
java.lang.Object
io.deephaven.engine.table.impl.util.TableTimeConversions
This class contains static methods to support conversions between various time types such as
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic Table
asEpochNanos
(@NotNull Table source, @NotNull MatchPair matchPair) Convert the specified column in the table to along
column of nanos since epoch.*static Table
asEpochNanos
(@NotNull Table source, @NotNull String column) Convert the specified column in the table to along
column of nanos since epoch.static Table
Convert the specified column in the table to anInstant
column.static Table
Convert the specified column in the table to anInstant
column.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.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.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.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.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.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.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.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.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.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.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.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.static boolean
isTimeType
(@NotNull Class<?> type) Check if the supplied type is one of the supported time types.static boolean
requiresZone
(@NotNull 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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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
public static Table asInstant(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair) Convert the specified column in the table to anInstant
column. -
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
public static Table asEpochNanos(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair) 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
-