public abstract class BaseDuration extends AbstractDuration implements ReadableDuration, java.io.Serializable
long
duration milliseconds field.
This class should generally not be used directly by API users.
The ReadableDuration
interface should be used when different
kinds of duration objects are to be referenced.
BaseDuration subclasses may be mutable and not thread-safe.
Modifier and Type | Method and Description |
---|---|
long |
getMillis()
Gets the length of this duration in milliseconds.
|
Interval |
toIntervalFrom(ReadableInstant startInstant)
Converts this duration to an Interval starting at the specified instant.
|
Interval |
toIntervalTo(ReadableInstant endInstant)
Converts this duration to an Interval ending at the specified instant.
|
Period |
toPeriod(Chronology chrono)
Converts this duration to a Period instance using the standard period type
and the specified chronology.
|
Period |
toPeriod(PeriodType type)
Converts this duration to a Period instance using the specified period type
and the ISO chronology.
|
Period |
toPeriod(PeriodType type,
Chronology chrono)
Converts this duration to a Period instance using the specified period type
and chronology.
|
Period |
toPeriodFrom(ReadableInstant startInstant)
Converts this duration to a Period instance by adding the duration to a start
instant to obtain an interval using the standard period type.
|
Period |
toPeriodFrom(ReadableInstant startInstant,
PeriodType type)
Converts this duration to a Period instance by adding the duration to a start
instant to obtain an interval.
|
Period |
toPeriodTo(ReadableInstant endInstant)
Converts this duration to a Period instance by subtracting the duration
from an end instant to obtain an interval using the standard period
type.
|
Period |
toPeriodTo(ReadableInstant endInstant,
PeriodType type)
Converts this duration to a Period instance by subtracting the duration
from an end instant to obtain an interval using the standard period
type.
|
compareTo, equals, hashCode, isEqual, isLongerThan, isShorterThan, toDuration, toPeriod, toString
equals, hashCode, isEqual, isLongerThan, isShorterThan, toDuration, toPeriod, toString
public long getMillis()
getMillis
in interface ReadableDuration
public Period toPeriod(PeriodType type)
Only precise fields in the period type will be used. At most these are hours, minutes, seconds and millis - the period type may restrict the selection further.
For more control over the conversion process, you must pair the duration with
an instant, see toPeriodFrom(ReadableInstant, PeriodType)
.
type
- the period type to use, null means standardpublic Period toPeriod(Chronology chrono)
Only precise fields in the period type will be used. Exactly which fields are precise depends on the chronology. Only the time fields are precise for ISO chronology with a time zone. However, ISO UTC also has precise days and weeks.
For more control over the conversion process, you must pair the duration with
an instant, see toPeriodFrom(ReadableInstant)
and
toPeriodTo(ReadableInstant)
chrono
- the chronology to use, null means ISO defaultpublic Period toPeriod(PeriodType type, Chronology chrono)
Only precise fields in the period type will be used. Exactly which fields are precise depends on the chronology. Only the time fields are precise for ISO chronology with a time zone. However, ISO UTC also has precise days and weeks.
For more control over the conversion process, you must pair the duration with
an instant, see toPeriodFrom(ReadableInstant, PeriodType)
and
toPeriodTo(ReadableInstant, PeriodType)
type
- the period type to use, null means standardchrono
- the chronology to use, null means ISO defaultpublic Period toPeriodFrom(ReadableInstant startInstant)
This conversion will determine the fields of a period accurately. The results are based on the instant millis, the chronology of the instant, the standard period type and the length of this duration.
startInstant
- the instant to calculate the period from, null means nowpublic Period toPeriodFrom(ReadableInstant startInstant, PeriodType type)
This conversion will determine the fields of a period accurately. The results are based on the instant millis, the chronology of the instant, the period type and the length of this duration.
startInstant
- the instant to calculate the period from, null means nowtype
- the period type determining how to split the duration into fields, null means All typepublic Period toPeriodTo(ReadableInstant endInstant)
This conversion will determine the fields of a period accurately. The results are based on the instant millis, the chronology of the instant, the standard period type and the length of this duration.
endInstant
- the instant to calculate the period to, null means nowpublic Period toPeriodTo(ReadableInstant endInstant, PeriodType type)
This conversion will determine the fields of a period accurately. The results are based on the instant millis, the chronology of the instant, the period type and the length of this duration.
endInstant
- the instant to calculate the period to, null means nowtype
- the period type determining how to split the duration into fields, null means All typepublic Interval toIntervalFrom(ReadableInstant startInstant)
startInstant
- the instant to start the interval at, null means nowpublic Interval toIntervalTo(ReadableInstant endInstant)
endInstant
- the instant to end the interval at, null means nowCopyright © 2010 - 2020 Adobe. All Rights Reserved