Class CompiledDateTimeFormat

java.lang.Object
org.apache.calcite.util.format.postgresql.CompiledDateTimeFormat

public class CompiledDateTimeFormat extends Object
Contains a parsed date/time format. Able to parse a string into a date/time value, or convert a date/time value to a string.
  • Constructor Details

    • CompiledDateTimeFormat

      public CompiledDateTimeFormat(com.google.common.collect.ImmutableList<CompiledItem> compiledItems)
  • Method Details

    • parseDateTime

      public ZonedDateTime parseDateTime(String input, ZoneId zoneId, Locale locale) throws ParseException
      Parses a date/time value from a string. The format used is in compiledItems.
      Parameters:
      input - the String to parse
      zoneId - timezone to convert the result to
      locale - Locale to use for parsing day or month names if the TM modifier was present
      Returns:
      the parsed date/time value
      Throws:
      ParseException - if the string to parse did not meet the required format
    • formatDateTime

      public String formatDateTime(ZonedDateTime dateTime, Locale locale)
      Converts a date/time value to a string. The output format is in compiledItems.
      Parameters:
      dateTime - date/time value to convert
      locale - Locale to use for outputting day and month names if the TM modifier was present
      Returns:
      the date/time value formatted as a String