Class PeriodParser
Period from a string
using the ISO8601 period format PnYnMnDTnHnMn.nS.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classParse values container created for each parse. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PeriodParserThe singleton instance.private static final StringUsed to validate the correct sequence of tokens.private static final StringThe standard string representing a zero period. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static PeriodParserGets the singleton instance of the parser.(package private) PeriodObtains an instance ofPeriodfrom a string.private voidparseDate(PeriodParser.ParseValues values, String s, int baseIndex) private intparseInt(PeriodParser.ParseValues values, String s, int baseIndex) private longparseNanos(PeriodParser.ParseValues values, String s, int baseIndex) private StringparseNumber(PeriodParser.ParseValues values, String s) private voidparseTime(PeriodParser.ParseValues values, String s, int baseIndex) private StringprepareTime(PeriodParser.ParseValues values, String s, int baseIndex) private voidvalidateCharactersAndOrdering(String s, String text)
-
Field Details
-
INSTANCE
The singleton instance. -
TOKEN_SEQUENCE
Used to validate the correct sequence of tokens.- See Also:
-
ZERO
-
-
Constructor Details
-
PeriodParser
private PeriodParser()Restricted constructor.
-
-
Method Details
-
getInstance
Gets the singleton instance of the parser.- Returns:
- the instance of the parser
-
parse
Obtains an instance ofPeriodfrom a string.This will parse the string produced by
toString()which is a subset of the ISO8601 period formatPnYnMnDTnHnMn.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
-
parseTime
-
parseNanos
-
prepareTime
-
parseInt
-
parseNumber
-
validateCharactersAndOrdering
-