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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TableasEpochNanos(@NotNull Table source, @NotNull MatchPair matchPair) Convert the specified column in the table to alongcolumn of nanos since epoch.*static TableasEpochNanos(@NotNull Table source, @NotNull String column) Convert the specified column in the table to alongcolumn of nanos since epoch.static TableConvert the specified column in the table to anInstantcolumn.static TableConvert the specified column in the table to anInstantcolumn.static TableasLocalDate(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone) Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone) Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(@NotNull Table source, @NotNull String column, @NotNull String zone) Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalDate(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone) Convert the specified column in the table to aLocalDatecolumn at the specified time zone.static TableasLocalTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone) Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone) Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(@NotNull Table source, @NotNull String column, @NotNull String zone) Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasLocalTime(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone) Convert the specified column in the table to aLocalTimecolumn at the specified time zone.static TableasZonedDateTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull String zone) Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(@NotNull Table source, @NotNull MatchPair matchPair, @NotNull ZoneId zone) Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(@NotNull Table source, @NotNull String column, @NotNull String zone) Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static TableasZonedDateTime(@NotNull Table source, @NotNull String column, @NotNull ZoneId zone) Convert the specified column in the table to aZonedDateTimecolumn at the specified time zone.static booleanisTimeType(@NotNull Class<?> type) Check if the supplied type is one of the supported time types.static booleanrequiresZone(@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 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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @NotNull String zone) Convert the specified column in the table to aLocalTimecolumn 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 aLocalTimecolumn 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 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 @NotNull Table source, @NotNull @NotNull String column, @NotNull @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 @NotNull Table source, @NotNull @NotNull MatchPair matchPair, @NotNull @NotNull String zone) Convert the specified column in the table to aLocalDatecolumn 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 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
public static Table asInstant(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair) Convert the specified column in the table to anInstantcolumn. -
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
public static Table asEpochNanos(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair) 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
-