Class TableTimeConversions

java.lang.Object
io.deephaven.engine.table.impl.util.TableTimeConversions

public class TableTimeConversions extends Object
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 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 a ZonedDateTime 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 table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to ZonedDateTime.
    • 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 a ZonedDateTime 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 table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to ZonedDateTime.
    • 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 a ZonedDateTime column at the specified time zone.
      Parameters:
      source - The source table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to ZonedDateTime.
    • 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 a ZonedDateTime column at the specified time zone.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to ZonedDateTime.
    • 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 a LocalTime 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 table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalTime.
    • 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 a LocalTime 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 table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalTime.
    • 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 a LocalTime column at the specified time zone.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalTime.
    • 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 a LocalTime column at the specified time zone.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalTime.
    • 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 a LocalDate 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 table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalDate.
    • 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 a LocalDate 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 table
      column - The column to convert, in MatchPair format
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalDate.
    • 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 a LocalDate column at the specified time zone.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalDate.
    • 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 a LocalDate column at the specified time zone.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      zone - The time zone to use.
      Returns:
      the Table with the specified column converted to LocalDate.
    • asInstant

      public static Table asInstant(@NotNull @NotNull Table source, @NotNull @NotNull String column)
      Convert the specified column in the table to an Instant column. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"
      Parameters:
      source - The source table
      column - The column to convert, in MatchPair format
      Returns:
      the Table with the specified column converted to Instant.
    • asInstant

      public static Table asInstant(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair)
      Convert the specified column in the table to an Instant column.
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      Returns:
      the Table with the specified column converted to Instant.
    • asEpochNanos

      public static Table asEpochNanos(@NotNull @NotNull Table source, @NotNull @NotNull String column)
      Convert the specified column in the table to a long column of nanos since epoch. The column may be specified as a single value "Column" or a pair "NewColumn = OriginalColumn"
      Parameters:
      source - The source table
      column - The column to convert, in MatchPair format
      Returns:
      the Table with the specified column converted to long.
    • asEpochNanos

      public static Table asEpochNanos(@NotNull @NotNull Table source, @NotNull @NotNull MatchPair matchPair)
      Convert the specified column in the table to a long column of nanos since epoch.*
      Parameters:
      source - The source table
      matchPair - The MatchPair of columns
      Returns:
      the Table with the specified column converted to long.
    • isTimeType

      public static boolean isTimeType(@NotNull @NotNull Class<?> type)
      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

      public static boolean requiresZone(@NotNull @NotNull Class<?> type)
      Check if the supplied time type requires a time zone for construction.
      Parameters:
      type - the type
      Returns:
      true if the type requires a timezone