public final class ClockInterval extends IsoInterval<PlainTime,ClockInterval> implements Serializable
Defines a finite wall time interval on the local timeline.
| Modifier and Type | Method and Description |
|---|---|
static ClockInterval |
between(LocalTime start,
LocalTime end)
Creates a finite half-open interval between given wall times.
|
static ClockInterval |
between(PlainTime start,
PlainTime end)
Creates a finite half-open interval between given wall times.
|
static Comparator<ChronoInterval<PlainTime>> |
comparator()
Defines a comparator which sorts intervals first
by start boundary and then by length.
|
String |
formatBasicISO(IsoDecimalStyle decimalStyle,
ClockUnit precision)
Prints the canonical form of this interval in given basic ISO-8601 style.
|
String |
formatExtendedISO(IsoDecimalStyle decimalStyle,
ClockUnit precision)
Prints the canonical form of this interval in given extended ISO-8601 style.
|
static ClockInterval |
from(ChronoInterval<PlainTime> interval)
Converts an arbitrary clock interval to an interval of this type.
|
Duration<ClockUnit> |
getDuration()
Yields the length of this interval.
|
PlainTime |
getEndAsClockTime()
Yields the end time point.
|
LocalTime |
getEndAsLocalTime()
Yields the end time point.
|
PlainTime |
getStartAsClockTime()
Yields the start time point.
|
LocalTime |
getStartAsLocalTime()
Yields the start time point.
|
ClockInterval |
move(long amount,
ClockUnit unit)
Moves this interval along the time axis by given units.
|
static ClockInterval |
parse(CharSequence text,
ChronoParser<PlainTime> parser,
BracketPolicy policy)
Interpretes given text as interval.
|
static ClockInterval |
parse(CharSequence text,
ChronoParser<PlainTime> parser,
BracketPolicy policy,
ParseLog status)
Deprecated.
Use one of other parse methods accepting a bracket policy instead
|
static ClockInterval |
parse(CharSequence text,
ChronoParser<PlainTime> startFormat,
char separator,
ChronoParser<PlainTime> endFormat,
BracketPolicy policy,
ParseLog status)
Interpretes given text as interval.
|
static ClockInterval |
parse(String text,
ChronoParser<PlainTime> parser)
Interpretes given text as interval using a localized interval pattern.
|
static ClockInterval |
parse(String text,
ChronoParser<PlainTime> parser,
String intervalPattern)
Interpretes given text as interval using given interval pattern.
|
static ClockInterval |
parseISO(String text)
Interpretes given ISO-conforming text as interval.
|
static ClockInterval |
since(LocalTime start)
Creates a finite half-open interval between given start time and
midnight at end of day (exclusive).
|
static ClockInterval |
since(PlainTime start)
Creates a finite half-open interval between given start time and
midnight at end of day (exclusive).
|
Stream<PlainTime> |
stream(Duration<ClockUnit> duration)
Obtains a stream iterating over every clock time which is the result of addition of given duration
to start until the end of this interval is reached.
|
static Stream<PlainTime> |
stream(Duration<ClockUnit> duration,
PlainTime start,
PlainTime end)
Obtains a stream iterating over every clock time which is the result of addition of given duration
to start until the end is reached.
|
static ClockInterval |
until(LocalTime end)
Creates a finite half-open interval between midnight at start of day
and given end time.
|
static ClockInterval |
until(PlainTime end)
Creates a finite half-open interval between midnight at start of day
and given end time.
|
abuts, collapse, contains, contains, enclosedBy, encloses, equals, equivalentTo, findIntersection, finishedBy, finishes, get, getEnd, getStart, hashCode, intersects, isAfter, isAfter, isBefore, isBefore, isEmpty, meets, metBy, overlappedBy, overlaps, precededBy, precedes, print, print, print, print, print, startedBy, starts, toCanonical, toString, withClosedEnd, withClosedStart, withEnd, withEnd, withOpenEnd, withOpenStart, withStart, withStart, withValueisFinitepublic static Comparator<ChronoInterval<PlainTime>> comparator()
Defines a comparator which sorts intervals first by start boundary and then by length.
public static ClockInterval between(PlainTime start, PlainTime end)
Creates a finite half-open interval between given wall times.
start - time of lower boundary (inclusive)end - time of upper boundary (exclusive)IllegalArgumentException - if start is after endpublic static ClockInterval between(LocalTime start, LocalTime end)
Creates a finite half-open interval between given wall times.
For better handling of time 24:00, it is recommended to directly use the overloaded variant with
arguments of type PlainTime.
start - time of lower boundary (inclusive)end - time of upper boundary (exclusive)IllegalArgumentException - if start is after endbetween(PlainTime, PlainTime)public static ClockInterval since(PlainTime start)
Creates a finite half-open interval between given start time and midnight at end of day (exclusive).
Note: The special wall time 24:00 does not belong to the created interval.
start - time of lower boundary (inclusive)public static ClockInterval since(LocalTime start)
Creates a finite half-open interval between given start time and midnight at end of day (exclusive).
start - time of lower boundary (inclusive)since(PlainTime)public static ClockInterval until(PlainTime end)
Creates a finite half-open interval between midnight at start of day and given end time.
end - time of upper boundary (exclusive)public static ClockInterval until(LocalTime end)
Creates a finite half-open interval between midnight at start of day and given end time.
end - time of upper boundary (exclusive)until(PlainTime)public static ClockInterval from(ChronoInterval<PlainTime> interval)
Converts an arbitrary clock interval to an interval of this type.
interval - any kind of clock intervalpublic PlainTime getStartAsClockTime()
Yields the start time point.
public LocalTime getStartAsLocalTime()
Yields the start time point.
public PlainTime getEndAsClockTime()
Yields the end time point.
public LocalTime getEndAsLocalTime()
Yields the end time point.
The end time 24:00 (midnight at end of day) will be mapped to midnight at start of next day (00:00).
public Duration<ClockUnit> getDuration()
Yields the length of this interval.
public ClockInterval move(long amount, ClockUnit unit)
Moves this interval along the time axis by given units.
amount - amount of unitsunit - time unit for movingpublic Stream<PlainTime> stream(Duration<ClockUnit> duration)
Obtains a stream iterating over every clock time which is the result of addition of given duration to start until the end of this interval is reached.
The stream size is limited to Integer.MAX_VALUE - 1 else an ArithmeticException
will be thrown.
duration - duration which has to be added to the start multiple timesIllegalArgumentException - if the duration is not positiveIllegalStateException - if this interval has no canonical formIsoInterval.toCanonical(),
stream(Duration, PlainTime, PlainTime)public static Stream<PlainTime> stream(Duration<ClockUnit> duration, PlainTime start, PlainTime end)
Obtains a stream iterating over every clock time which is the result of addition of given duration to start until the end is reached.
This static method avoids the costs of constructing an instance of ClockInterval.
The stream size is limited to Integer.MAX_VALUE - 1 else an ArithmeticException
will be thrown.
duration - duration which has to be added to the start multiple timesstart - start boundary - inclusiveend - end boundary - exclusiveIllegalArgumentException - if start is after end or if the duration is not positivepublic String formatBasicISO(IsoDecimalStyle decimalStyle, ClockUnit precision)
Prints the canonical form of this interval in given basic ISO-8601 style.
decimalStyle - iso-compatible decimal styleprecision - controls the precision of output format with constant lengthIllegalStateException - if there is no canonical form (for example for [00:00/24:00])IsoInterval.toCanonical()public String formatExtendedISO(IsoDecimalStyle decimalStyle, ClockUnit precision)
Prints the canonical form of this interval in given extended ISO-8601 style.
decimalStyle - iso-compatible decimal styleprecision - controls the precision of output format with constant lengthIllegalStateException - if there is no canonical form (for example for [00:00/24:00])IsoInterval.toCanonical()public static ClockInterval parse(String text, ChronoParser<PlainTime> parser) throws ParseException
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.
text - text to be parsedparser - format object for parsing start and end componentsIndexOutOfBoundsException - if given text is emptyParseException - if the text is not parseableparse(String, ChronoParser, String),
FormatPatternProvider.getIntervalPattern(Locale)public static ClockInterval parse(String text, ChronoParser<PlainTime> parser, String intervalPattern) throws ParseException
Interpretes given text as interval using given interval pattern.
About usage see also DateInterval.parse(String, ChronoParser, String).
text - text to be parsedparser - format object for parsing start and end componentsintervalPattern - interval pattern containing placeholders {0} and {1} (for start and end)IndexOutOfBoundsException - if given text is emptyParseException - if the text is not parseablepublic static ClockInterval parse(CharSequence text, ChronoParser<PlainTime> parser, BracketPolicy policy) throws ParseException
Interpretes given text as interval.
This method can also accept a hyphen as alternative to solidus as separator between start and end component unless the start component is a period.
text - text to be parsedparser - format object for parsing start and end componentspolicy - strategy for parsing interval boundariesParseException - if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behind@Deprecated public static ClockInterval parse(CharSequence text, ChronoParser<PlainTime> parser, BracketPolicy policy, ParseLog status)
Interpretes given text as interval.
Similar to parse(CharSequence, ChronoParser, char, ChronoParser, BracketPolicy, ParseLog).
Since version v3.9/4.6 this method can also accept a hyphen as alternative to solidus as separator
between start and end component unless the start component is a period.
text - text to be parsedparser - format object for parsing start and end componentspolicy - strategy for parsing interval boundariesstatus - parser information (always as new instance)null if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behindpublic static ClockInterval parse(CharSequence text, ChronoParser<PlainTime> startFormat, char separator, ChronoParser<PlainTime> endFormat, BracketPolicy policy, ParseLog status)
Interpretes given text as interval.
This method is mainly intended for parsing technical interval formats similar to ISO-8601 which are not localized.
text - text to be parsedstartFormat - format object for parsing start componentseparator - char separating start and end componentendFormat - format object for parsing end componentpolicy - strategy for parsing interval boundariesstatus - parser information (always as new instance)null if parsing does not workIndexOutOfBoundsException - if the start position is at end of text or even behindpublic static ClockInterval parseISO(String text) throws ParseException
Interpretes given ISO-conforming text as interval.
Examples for supported formats:
text - text to be parsedIndexOutOfBoundsException - if given text is emptyParseException - if the text is not parseableBracketPolicy.SHOW_NEVERCopyright © 2014–2018. All rights reserved.