Class DateTimeCompatibility

java.lang.Object
io.deephaven.enterprise.compatibility.DateTimeCompatibility

public class DateTimeCompatibility extends Object
Class to handle compatibility issues with legacy date-time parsing in Deephaven. Functionality is mostly taken from DBDateTime and DBTimeUtils. Some of this is shadowed but it should be legitimately available in core plus.
  • Constructor Details

    • DateTimeCompatibility

      public DateTimeCompatibility()
  • Method Details

    • convertDateTime

      @NotNull public static @NotNull Instant convertDateTime(String s)
      Converts a DateTime String from a few specific zoned formats to an Instant and throws an exception if the format is not recognized.
      Parameters:
      s - string to be converted, usually in the form yyyy-MM-ddThh:mm:ss and with optional sub-seconds after an optional decimal point, followed by a mandatory time zone character code
      Returns:
      an Instant from the parsed String
      Throws:
      IllegalArgumentException - if the string cannot be parsed
    • convertDateTimeQuiet

      @Nullable public static @Nullable Instant convertDateTimeQuiet(String s)
      Converts a DateTime String from a few specific zoned formats to an Instant. Based on DBTimeUtils#convertDateTimeQuiet.
      Parameters:
      s - string to be converted, usually in the form yyyy-MM-ddThh:mm:ss and with optional sub-seconds after an optional decimal point, followed by a mandatory time zone character code
      Returns:
      an Instant from the parsed String, or null if the format is not recognized or an exception occurs
    • convertLegacyDateTimeQuiet

      @Deprecated public static Instant convertLegacyDateTimeQuiet(String s)
      Deprecated.
      Parse a time string that matches LEGACY_DATETIME_PATTERN.
      Parameters:
      s - the string to be parsed
      Returns:
      an Instant from the parsed string
    • convertLegacyMicrosDateTimeQuiet

      @Deprecated public static Instant convertLegacyMicrosDateTimeQuiet(String s)
      Deprecated.
      Parse a time string that matches LEGACY_MICROS_DATETIME_PATTERN.
      Parameters:
      s - the string to be parsed
      Returns:
      an Instant from the parsed string
    • toLegacyString

      @NotNull public static @NotNull String toLegacyString(@NotNull @NotNull Instant dateTime, @NotNull @NotNull DateTimeCompatibility.DBTimeZone timeZone)
      Convert this Instant into a String using the provided DateTimeCompatibility.DBTimeZone. Similar to DBDateTime#toString.

      The date will be formatted as yyyy-MM-DDThh:mm:ss.SSSSSSSSS TZ, for example 2020-05-27T13:37:57.780853000 NY or 2020-05-27T17:37:42.763641000 UTC.

      Parameters:
      dateTime - the Instant to be converted
      timeZone - the DateTimeCompatibility.DBTimeZone for formatting the string
      Returns:
      a String representation of this DateTimeCompatibility.DBTimeZone