Class PeriodParser

java.lang.Object
javax.time.calendar.PeriodParser

final class PeriodParser extends Object
An period parser that creates an instance of Period from a string using the ISO8601 period format PnYnMnDTnHnMn.nS.
  • Field Details

    • INSTANCE

      private static final PeriodParser INSTANCE
      The singleton instance.
    • TOKEN_SEQUENCE

      private static final String TOKEN_SEQUENCE
      Used to validate the correct sequence of tokens.
      See Also:
    • ZERO

      private static final String ZERO
      The standard string representing a zero period.
      See Also:
  • Constructor Details

    • PeriodParser

      private PeriodParser()
      Restricted constructor.
  • Method Details

    • getInstance

      static PeriodParser getInstance()
      Gets the singleton instance of the parser.
      Returns:
      the instance of the parser
    • parse

      Period parse(String text)
      Obtains an instance of Period from a string.

      This will parse the string produced by toString() which is a subset of the ISO8601 period format PnYnMnDTnHnMn.nS.

      The string consists of a series of numbers with a suffix identifying their meaning. The values, and suffixes, must be in the sequence year, month, day, hour, minute, second. Any of the number/suffix pairs may be omitted providing at least one is present. If the period is zero, the value is normally represented as PT0S. The numbers must consist of ASCII digits. Any of the numbers may be negative. Negative zero is not accepted. The number of nanoseconds is expressed as an optional fraction of the seconds. There must be at least one digit before any decimal point. There must be between 1 and 9 inclusive digits after any decimal point. The letters will all be accepted in upper or lower case. The decimal point may be either a dot or a comma.

      Parameters:
      text - the input string in the format PnYnMnDTnHnMn.nS, validated not null
      Returns:
      the created Period, never null
      Throws:
      CalendricalParseException - if the text cannot be parsed to a Period
    • parseDate

      private void parseDate(PeriodParser.ParseValues values, String s, int baseIndex)
    • parseTime

      private void parseTime(PeriodParser.ParseValues values, String s, int baseIndex)
    • parseNanos

      private long parseNanos(PeriodParser.ParseValues values, String s, int baseIndex)
    • prepareTime

      private String prepareTime(PeriodParser.ParseValues values, String s, int baseIndex)
    • parseInt

      private int parseInt(PeriodParser.ParseValues values, String s, int baseIndex)
    • parseNumber

      private String parseNumber(PeriodParser.ParseValues values, String s)
    • validateCharactersAndOrdering

      private void validateCharactersAndOrdering(String s, String text)