Package net.time4j.range
Class SimpleInterval.Factory<T>
java.lang.Object
net.time4j.range.SimpleInterval.Factory<T>
- Type Parameters:
T
- generic type of timepoints on the underlying timeline
- Enclosing class:
- SimpleInterval<T>
Serves for the creation of generic simple intervals on a timeline.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new interval between given boundaries.parse(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.Creates a new interval since given start.Creates a new interval until given end.
-
Method Details
-
between
Creates a new interval between given boundaries.
- Parameters:
start
- the start of interval (always inclusive)end
- the end of interval (inclusive if calendrical else exclusive)- Returns:
- new interval (closed if calendrical else half-open)
-
since
Creates a new interval since given start.
- Parameters:
start
- the start of interval (inclusive)- Returns:
- new interval (half-open and infinite)
-
until
Creates a new interval until given end.
- Parameters:
end
- the end of interval (inclusive if calendrical else exclusive)- Returns:
- new infinite interval
-
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 SimpleInterval<T> parse(CharSequence text, ChronoParser<T> parser, String intervalPattern) throws ParseExceptionInterpretes given text as interval using given interval pattern.
For version v4.21 or later, 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
-