public static class Duration.Builder extends Object
Builder class for constructing a duration conforming to ISO-8601 which consists of years, months, days and any wall time units.
The week unit is not possible in builder because this unit should
be stand-alone according to ISO-8601. A week-based duration can be
created by expression Duration.of(amount, CalendarUnit.WEEKS)
however.
A builder instance must be created by Duration.ofPositive()
or Duration.ofNegative(). Note that the builder is only be
designed for single-thread-environments that is always creating a
new builder instance per thread.
| Modifier and Type | Method and Description |
|---|---|
Duration<IsoUnit> |
build()
Creates a new duration conforming to ISO-8601.
|
Duration.Builder |
days(int num)
Adds a day item.
|
Duration.Builder |
hours(int num)
Adds a hour item.
|
Duration.Builder |
micros(int num)
Adds a microsecond item.
|
Duration.Builder |
millis(int num)
Adds a millisecond item.
|
Duration.Builder |
minutes(int num)
Adds a minute item.
|
Duration.Builder |
months(int num)
Adds a month item.
|
Duration.Builder |
nanos(int num)
Adds a nanosecond item.
|
Duration.Builder |
seconds(int num)
Adds a second item.
|
Duration.Builder |
years(int num)
Adds a year item.
|
public Duration.Builder years(int num)
Adds a year item.
num - count of years >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledCalendarUnit.YEARSpublic Duration.Builder months(int num)
Adds a month item.
num - count of months >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledCalendarUnit.MONTHSpublic Duration.Builder days(int num)
Adds a day item.
num - count of days >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledCalendarUnit.DAYSpublic Duration.Builder hours(int num)
Adds a hour item.
num - count of hours >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledClockUnit.HOURSpublic Duration.Builder minutes(int num)
Adds a minute item.
num - count of minutes >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledClockUnit.MINUTESpublic Duration.Builder seconds(int num)
Adds a second item.
num - count of seconds >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledClockUnit.SECONDSpublic Duration.Builder millis(int num)
Adds a millisecond item.
The argument will automatically be normalized to nanoseconds.
num - count of milliseconds >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledpublic Duration.Builder micros(int num)
Adds a microsecond item.
The argument will automatically be normalized to nanoseconds.
num - count of microseconds >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledpublic Duration.Builder nanos(int num)
Adds a nanosecond item.
num - count of nanoseconds >= 0IllegalArgumentException - if the argument is negativeIllegalStateException - if already calledClockUnit.NANOSCopyright © 2014. All rights reserved.