Class DateTimeFormatterBuilder.ZoneIdPrinterParser

java.lang.Object
org.threeten.bp.format.DateTimeFormatterBuilder.ZoneIdPrinterParser
All Implemented Interfaces:
DateTimeFormatterBuilder.DateTimePrinterParser
Enclosing class:
DateTimeFormatterBuilder

static final class DateTimeFormatterBuilder.ZoneIdPrinterParser extends Object implements DateTimeFormatterBuilder.DateTimePrinterParser
Prints or parses a zone ID.
  • Field Details

  • Constructor Details

  • Method Details

    • print

      public boolean print(DateTimePrintContext context, StringBuilder buf)
      Description copied from interface: DateTimeFormatterBuilder.DateTimePrinterParser
      Prints the date-time object to the buffer.

      The context holds information to use during the print. It also contains the date-time information to be printed.

      The buffer must not be mutated beyond the content controlled by the implementation.

      Specified by:
      print in interface DateTimeFormatterBuilder.DateTimePrinterParser
      Parameters:
      context - the context to print using, not null
      buf - the buffer to append to, not null
      Returns:
      false if unable to query the value from the date-time, true otherwise
    • parse

      public int parse(DateTimeParseContext context, CharSequence text, int position)
      This implementation looks for the longest matching string. For example, parsing Etc/GMT-2 will return Etc/GMC-2 rather than just Etc/GMC although both are valid.

      This implementation uses a tree to search for valid time-zone names in the parseText. The top level node of the tree has a length equal to the length of the shortest time-zone as well as the beginning characters of all other time-zones.

      Specified by:
      parse in interface DateTimeFormatterBuilder.DateTimePrinterParser
      Parameters:
      context - the context to use and parse into, not null
      text - the input text to parse, not null
      position - the position to start parsing at, from 0 to the text length
      Returns:
      the new parse position, where negative means an error with the error position encoded using the complement ~ operator
    • convertToZone

      private ZoneId convertToZone(Set<String> regionIds, String parsedZoneId, boolean caseSensitive)
    • parsePrefixedOffset

      private int parsePrefixedOffset(DateTimeParseContext context, CharSequence text, int prefixPos, int position)
    • prepareParser

      private static DateTimeFormatterBuilder.ZoneIdPrinterParser.SubstringTree prepareParser(Set<String> availableIDs)
      Builds an optimized parsing tree.
      Parameters:
      availableIDs - the available IDs, not null, not empty
      Returns:
      the tree, not null
    • toString

      public String toString()
      Overrides:
      toString in class Object