Class PeriodParser
Period
from a string
using the ISO8601 period format PnYnMnDTnHnMn.nS
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Parse values container created for each parse. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PeriodParser
The singleton instance.private static final String
Used to validate the correct sequence of tokens.private static final String
The standard string representing a zero period. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static PeriodParser
Gets the singleton instance of the parser.(package private) Period
Obtains an instance ofPeriod
from a string.private void
parseDate
(PeriodParser.ParseValues values, String s, int baseIndex) private int
parseInt
(PeriodParser.ParseValues values, String s, int baseIndex) private long
parseNanos
(PeriodParser.ParseValues values, String s, int baseIndex) private String
parseNumber
(PeriodParser.ParseValues values, String s) private void
parseTime
(PeriodParser.ParseValues values, String s, int baseIndex) private String
prepareTime
(PeriodParser.ParseValues values, String s, int baseIndex) private void
validateCharactersAndOrdering
(String s, String text)
-
Field Details
-
INSTANCE
The singleton instance. -
TOKEN_SEQUENCE
Used to validate the correct sequence of tokens.- See Also:
-
ZERO
The standard string representing a zero period.- See Also:
-
-
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 ofPeriod
from 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
-