Package net.time4j.range
Class CalendarPeriod.Parser<T>
java.lang.Object
net.time4j.range.CalendarPeriod.Parser<T>
- Type Parameters:
T
- generic type of timepoints on the underlying timeline
- Direct Known Subclasses:
CalendarPeriod.Factory
- Enclosing class:
- CalendarPeriod<T>
Serves for parsing of any calendar intervals on a timeline.
-
Method Summary
Modifier and TypeMethodDescriptionparse(CharSequence text, ChronoParser<T> parser)
Interpretes given text as interval using a localized interval pattern.parse(CharSequence text, ChronoParser<T> parser, String intervalPattern)
Interpretes given text as interval using given interval pattern.
-
Method Details
-
parse
Interpretes given text as interval using a localized interval pattern.
If given parser does not contain a reference to a locale then the interval pattern "{0}/{1}" will be used.
- Parameters:
text
- text to be parsedparser
- format object for parsing start and end components- Returns:
- parsed interval (closed if calendrical else half-open)
- Throws:
IndexOutOfBoundsException
- if given text is emptyParseException
- if the text is not parseable- See Also:
parse(CharSequence, ChronoParser, String)
-
parse
public CalendarPeriod<T> parse(CharSequence text, ChronoParser<T> parser, String intervalPattern) throws ParseExceptionInterpretes given text as interval using given interval pattern.
It is also possible to use an or-pattern logic. Example see
DateInterval.parse(String, ChronoParser, String)
.- Parameters:
text
- text to be parsedparser
- format object for parsing start and end componentsintervalPattern
- interval pattern containing placeholders {0} and {1} (for start and end)- Returns:
- parsed interval (closed if calendrical else half-open)
- Throws:
IndexOutOfBoundsException
- if given text is emptyParseException
- if the text is not parseable
-