

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object javax.time.calendar.Period
public final class Period
An immutable period consisting of the ISO8601 year, month, day, hour, minute, second and nanosecond units, such as '3 Months, 4 Days and 7 Hours'.
A period is a humanscale description of an amount of time.
This class represents the 7 standard definitions from ISOChronology
.
The period units used are 'Years', 'Months', 'Days', 'Hours', 'Minutes',
'Seconds' and 'Nanoseconds'.
The ISOChronology
defines a relationship between some of the units:
Period is immutable and threadsafe.
Field Summary  

static Period 
ZERO
A constant for a period of zero. 
Method Summary  

static Period 
between(LocalDate startDate,
LocalDate endDate)
Obtains a Period consisting of the number of days, months
and years between two dates. 
static Period 
daysBetween(LocalDate startDate,
LocalDate endDate)
Obtains a Period consisting of the number of days between two dates. 
Period 
dividedBy(int divisor)
Returns a new instance with each element in this period divided by the specified value. 
boolean 
equals(java.lang.Object obj)
Checks if this period is equal to another period. 
int 
getDays()
Gets the amount of days of this period, if any. 
int 
getHours()
Gets the amount of hours of this period, if any. 
int 
getMinutes()
Gets the amount of minutes of this period, if any. 
int 
getMonths()
Gets the amount of months of this period, if any. 
long 
getNanos()
Gets the amount of nanoseconds of this period, if any. 
int 
getNanosInt()
Gets the amount of nanoseconds of this period safely converted to an int . 
int 
getSeconds()
Gets the amount of seconds of this period, if any. 
int 
getYears()
Gets the amount of years of this period, if any. 
int 
hashCode()
A hash code for this period. 
boolean 
isPositive()
Checks if this period is fully positive, excluding zero. 
boolean 
isPositiveOrZero()
Checks if this period is fully positive, including zero. 
boolean 
isZero()
Checks if this period is zerolength. 
Period 
minus(PeriodProvider periodProvider)
Returns a copy of this period with the specified period subtracted. 
Period 
minusDays(int days)
Returns a copy of this period with the specified number of days subtracted. 
Period 
minusHours(int hours)
Returns a copy of this period with the specified number of hours subtracted. 
Period 
minusMinutes(int minutes)
Returns a copy of this period with the specified number of minutes subtracted. 
Period 
minusMonths(int months)
Returns a copy of this period with the specified number of months subtracted. 
Period 
minusNanos(long nanos)
Returns a copy of this period with the specified number of nanoseconds subtracted. 
Period 
minusSeconds(int seconds)
Returns a copy of this period with the specified number of seconds subtracted. 
Period 
minusYears(int years)
Returns a copy of this period with the specified number of years subtracted. 
static Period 
monthsBetween(LocalDate startDate,
LocalDate endDate)
Obtains a Period consisting of the number of months between two dates. 
Period 
multipliedBy(int scalar)
Returns a new instance with each element in this period multiplied by the specified scalar. 
Period 
negated()
Returns a new instance with each amount in this period negated. 
Period 
normalized()
Returns a copy of this period with all amounts normalized to the standard ranges for datetime fields. 
Period 
normalizedWith24HourDays()
Returns a copy of this period with all amounts normalized to the standard ranges for datetime fields including the assumption that days are 24 hours long. 
static Period 
of(Duration duration)
Obtains a Period from a Duration . 
static Period 
of(int years,
int months,
int days,
int hours,
int minutes,
int seconds)
Obtains a Period from datebased and timebased fields. 
static Period 
of(int years,
int months,
int days,
int hours,
int minutes,
int seconds,
long nanos)
Obtains a Period from datebased and timebased fields. 
static Period 
of(int amount,
PeriodUnit unit)
Obtains a Period from an amount and unit. 
static Period 
of(PeriodProvider periodProvider)
Obtains a Period from a provider of periods. 
static Period 
ofDateFields(int years,
int months,
int days)
Obtains a Period from datebased fields. 
static Period 
ofDateFields(PeriodProvider periodProvider)
Obtains a Period from the datebased fields of a period. 
static Period 
ofDays(int days)
Obtains a Period from a number of days. 
static Period 
ofHours(int hours)
Obtains a Period from a number of hours. 
static Period 
ofMinutes(int minutes)
Obtains a Period from a number of minutes. 
static Period 
ofMonths(int months)
Obtains a Period from a number of months. 
static Period 
ofNanos(long nanos)
Obtains a Period from a number of nanoseconds. 
static Period 
ofSeconds(int seconds)
Obtains a Period from a number of seconds. 
static Period 
ofTimeFields(int hours,
int minutes,
int seconds)
Obtains a Period from timebased fields. 
static Period 
ofTimeFields(int hours,
int minutes,
int seconds,
long nanos)
Obtains a Period from timebased fields. 
static Period 
ofTimeFields(PeriodProvider periodProvider)
Obtains a Period from the timebased fields of a period. 
static Period 
ofYears(int years)
Obtains a Period from a number of years. 
static Period 
parse(java.lang.CharSequence text)
Obtains a Period from a text string such as PnYnMnDTnHnMn.nS . 
Period 
plus(PeriodProvider periodProvider)
Returns a copy of this period with the specified period added. 
Period 
plusDays(int days)
Returns a copy of this period with the specified number of days added. 
Period 
plusHours(int hours)
Returns a copy of this period with the specified number of hours added. 
Period 
plusMinutes(int minutes)
Returns a copy of this period with the specified number of minutes added. 
Period 
plusMonths(int months)
Returns a copy of this period with the specified number of months added. 
Period 
plusNanos(long nanos)
Returns a copy of this period with the specified number of nanoseconds added. 
Period 
plusSeconds(int seconds)
Returns a copy of this period with the specified number of seconds added. 
Period 
plusYears(int years)
Returns a copy of this period with the specified number of years added. 
Duration 
toDuration()
Calculates the accurate duration of this period. 
Duration 
toDurationWith24HourDays()
Calculates the accurate duration of this period. 
Duration 
toEstimatedDuration()
Estimates the duration of this period. 
PeriodFields 
toPeriodFields()
Converts this period to a PeriodFields . 
java.lang.String 
toString()
Outputs this period as a String , such as P6Y3M1DT12H . 
long 
totalDaysWith24HourDays()
Gets the total number of days represented by this period using standard assumptions for the meaning of day, hour, minute and second. 
long 
totalHours()
Gets the total number of hours represented by this period using standard assumptions for the meaning of hour, minute and second. 
long 
totalHoursWith24HourDays()
Gets the total number of hours represented by this period using standard assumptions for the meaning of day, hour, minute and second. 
long 
totalMinutes()
Gets the total number of minutes represented by this period using standard assumptions for the meaning of hour, minute and second. 
long 
totalMinutesWith24HourDays()
Gets the total number of minutes represented by this period using standard assumptions for the meaning of day, hour, minute and second. 
long 
totalMonths()
Gets the total number of months represented by this period using standard assumptions for the meaning of month. 
long 
totalNanos()
Gets the total number of nanoseconds represented by this period using standard assumptions for the meaning of hour, minute and second. 
long 
totalNanosWith24HourDays()
Gets the total number of nanoseconds represented by this period using standard assumptions for the meaning of day, hour, minute and second. 
long 
totalSeconds()
Gets the total number of seconds represented by this period using standard assumptions for the meaning of hour, minute and second. 
long 
totalSecondsWith24HourDays()
Gets the total number of seconds represented by this period using standard assumptions for the meaning of day, hour, minute and second. 
long 
totalYears()
Gets the total number of years represented by this period using standard assumptions for the meaning of month. 
Period 
withDateFieldsOnly()
Returns a copy of this period with only the datebased fields retained. 
Period 
withDays(int days)
Returns a copy of this period with the specified amount of days. 
Period 
withHours(int hours)
Returns a copy of this period with the specified amount of hours. 
Period 
withMinutes(int minutes)
Returns a copy of this period with the specified amount of minutes. 
Period 
withMonths(int months)
Returns a copy of this period with the specified amount of months. 
Period 
withNanos(long nanos)
Returns a copy of this period with the specified amount of nanoseconds. 
Period 
withSeconds(int seconds)
Returns a copy of this period with the specified amount of seconds. 
Period 
withTimeFieldsOnly()
Returns a copy of this period with only the timebased fields retained. 
Period 
withYears(int years)
Returns a copy of this period with the specified amount of years. 
static Period 
yearsBetween(LocalDate startDate,
LocalDate endDate)
Obtains a Period consisting of the number of years between two dates. 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Field Detail 

public static final Period ZERO
Method Detail 

public static Period of(int years, int months, int days, int hours, int minutes, int seconds)
Period
from datebased and timebased fields.
This creates an instance based on years, months, days, hours, minutes and seconds.
years
 the amount of years, may be negativemonths
 the amount of months, may be negativedays
 the amount of days, may be negativehours
 the amount of hours, may be negativeminutes
 the amount of minutes, may be negativeseconds
 the amount of seconds, may be negative
public static Period of(int years, int months, int days, int hours, int minutes, int seconds, long nanos)
Period
from datebased and timebased fields.
This creates an instance based on years, months, days, hours, minutes, seconds and nanoseconds. The resulting period will have normalized seconds and nanoseconds.
years
 the amount of years, may be negativemonths
 the amount of months, may be negativedays
 the amount of days, may be negativehours
 the amount of hours, may be negativeminutes
 the amount of minutes, may be negativeseconds
 the amount of seconds, may be negativenanos
 the amount of nanos, may be negative
public static Period of(PeriodProvider periodProvider)
Period
from a provider of periods.
A Period
supports 7 units, ISO years, months, days, hours,
minutes, seconds and nanoseconds. Any period that contains amounts in
these units, or in units that can be converted to these units will be
accepted. If the provider contains any other unit, an exception is thrown.
periodProvider
 a provider of period information, not null
CalendricalException
 if the provided period cannot be converted to the supported units
java.lang.ArithmeticException
 if any provided amount, exceeds the supported rangepublic static Period ofDateFields(int years, int months, int days)
Period
from datebased fields.
This creates an instance based on years, months and days.
years
 the amount of years, may be negativemonths
 the amount of months, may be negativedays
 the amount of days, may be negative
public static Period ofDateFields(PeriodProvider periodProvider)
Period
from the datebased fields of a period.
A Period
supports 7 units, ISO years, months, days, hours,
minutes, seconds and nanoseconds. Any period that contains amounts in
these units, or in units that can be converted to these units will be
accepted. If the provider contains any other unit, an exception is thrown.
Once the initial conversion to the 7 units is complete, the period is created using just the datebased fields  years, months and days. The timebased fields are ignored and will be zero in the created period.
periodProvider
 a provider of period information, not null
CalendricalException
 if the provided period cannot be converted to the supported units
java.lang.ArithmeticException
 if any provided amount, exceeds the supported rangepublic static Period ofTimeFields(int hours, int minutes, int seconds)
Period
from timebased fields.
This creates an instance based on hours, minutes and seconds.
hours
 the amount of hours, may be negativeminutes
 the amount of minutes, may be negativeseconds
 the amount of seconds, may be negative
public static Period ofTimeFields(int hours, int minutes, int seconds, long nanos)
Period
from timebased fields.
This creates an instance based on hours, minutes, seconds and nanoseconds.
hours
 the amount of hours, may be negativeminutes
 the amount of minutes, may be negativeseconds
 the amount of seconds, may be negativenanos
 the amount of nanos, may be negative
public static Period ofTimeFields(PeriodProvider periodProvider)
Period
from the timebased fields of a period.
A Period
supports 7 units, ISO years, months, days, hours,
minutes, seconds and nanoseconds. Any period that contains amounts in
these units, or in units that can be converted to these units will be
accepted. If the provider contains any other unit, an exception is thrown.
Once the initial conversion to the 7 units is complete, the period is created using just the timebased fields  hours, minutes, seconds and nanoseconds. The datebased fields are ignored and will be zero in the created period.
periodProvider
 a provider of period information, not null
CalendricalException
 if the provided period cannot be converted to the supported units
java.lang.ArithmeticException
 if any provided amount, exceeds the supported rangepublic static Period of(int amount, PeriodUnit unit)
Period
from an amount and unit.
The parameters represent the two parts of a phrase like '6 Days'.
A Period
supports 7 units, ISO years, months, days, hours,
minutes, seconds and nanoseconds. The unit must be one of these, or be
able to be converted to one of these.
amount
 the amount of the period, measured in terms of the unit, positive or negativeunit
 the unit that the period is measured in, not null
public static Period ofYears(int years)
Period
from a number of years.
years
 the amount of years, may be negative
public static Period ofMonths(int months)
Period
from a number of months.
months
 the amount of months, may be negative
public static Period ofDays(int days)
Period
from a number of days.
days
 the amount of days, may be negative
public static Period ofHours(int hours)
Period
from a number of hours.
hours
 the amount of hours, may be negative
public static Period ofMinutes(int minutes)
Period
from a number of minutes.
minutes
 the amount of minutes, may be negative
public static Period ofSeconds(int seconds)
Period
from a number of seconds.
seconds
 the amount of seconds, may be negative
public static Period ofNanos(long nanos)
Period
from a number of nanoseconds.
nanos
 the amount of nanos, may be negative
public static Period of(Duration duration)
Period
from a Duration
.
The created period will have normalized values for the hours, minutes, seconds and nanoseconds fields. The years, months and days fields will be zero.
To populate the days field, call normalizedWith24HourDays()
on the created period.
duration
 the duration to create from, not null
PeriodFields
instance, not null
java.lang.ArithmeticException
 if the result exceeds the supported period rangepublic static Period between(LocalDate startDate, LocalDate endDate)
Period
consisting of the number of days, months
and years between two dates.
The start date is included, but the end date is not. Only whole years count.
For example, from 20100115
to 20110318
is one year, two months and three days.
The result of this method can be a negative period if the end is before the start. The negative sign will be the same in each of year, month and day.
Adding the result of this method to the start date will always yield the end date.
startDate
 the start date, inclusive, not nullendDate
 the end date, exclusive, not null
java.lang.ArithmeticException
 if the period exceeds the supported rangepublic static Period yearsBetween(LocalDate startDate, LocalDate endDate)
Period
consisting of the number of years between two dates.
The start date is included, but the end date is not. Only whole years count.
For example, from 20100115
to 20120115
is two years,
whereas from 20100115
to 20120114
is only one year.
The result of this method can be a negative period if the end is before the start.
startDate
 the start date, inclusive, not nullendDate
 the end date, exclusive, not null
java.lang.ArithmeticException
 if the period exceeds the supported rangepublic static Period monthsBetween(LocalDate startDate, LocalDate endDate)
Period
consisting of the number of months between two dates.
The start date is included, but the end date is not. Only whole months count.
For example, from 20100115
to 20100315
is two months,
whereas from 20100115
to 20100314
is only one month.
The result of this method can be a negative period if the end is before the start.
startDate
 the start date, inclusive, not nullendDate
 the end date, exclusive, not null
java.lang.ArithmeticException
 if the period exceeds the supported rangepublic static Period daysBetween(LocalDate startDate, LocalDate endDate)
Period
consisting of the number of days between two dates.
The start date is included, but the end date is not. For example, from
20100115
to 20100118
is three days.
The result of this method can be a negative period if the end is before the start.
startDate
 the start date, inclusive, not nullendDate
 the end date, exclusive, not null
java.lang.ArithmeticException
 if the period exceeds the supported rangepublic static Period parse(java.lang.CharSequence text)
Period
from a text string such as PnYnMnDTnHnMn.nS
.
This will parse the string produced by toString()
which is
a subset of the ISO8601 period format PnYnMnDTnHnMn.nS
.
The string consists of a series of numbers with a suffix identifying their meaning.
The values, and suffixes, must be in the sequence year, month, day, hour, minute, second.
Any of the number/suffix pairs may be omitted providing at least one is present.
If the period is zero, the value is normally represented as PT0S
.
The numbers must consist of ASCII digits.
Any of the numbers may be negative. Negative zero is not accepted.
The number of nanoseconds is expressed as an optional fraction of the seconds.
There must be at least one digit before any decimal point.
There must be between 1 and 9 inclusive digits after any decimal point.
The letters will all be accepted in upper or lower case.
The decimal point may be either a dot or a comma.
text
 the text to parse, not null
CalendricalParseException
 if the text cannot be parsed to a Periodpublic boolean isZero()
public boolean isPositive()
This checks whether all the amounts in the period are positive, defined as greater than zero.
public boolean isPositiveOrZero()
This checks whether all the amounts in the period are positive, defined as greater than or equal to zero.
public int getYears()
public int getMonths()
public int getDays()
public int getHours()
public int getMinutes()
public int getSeconds()
public long getNanos()
public int getNanosInt()
int
.
java.lang.ArithmeticException
 if the number of nanoseconds exceeds the capacity of an int
public Period withYears(int years)
This method will only affect the years field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
years
 the years to represent
Period
based on this period with the requested years, not nullpublic Period withMonths(int months)
This method will only affect the months field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
months
 the months to represent
Period
based on this period with the requested months, not nullpublic Period withDays(int days)
This method will only affect the days field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
days
 the days to represent
Period
based on this period with the requested days, not nullpublic Period withHours(int hours)
This method will only affect the hours field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
hours
 the hours to represent
Period
based on this period with the requested hours, not nullpublic Period withMinutes(int minutes)
This method will only affect the minutes field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
minutes
 the minutes to represent
Period
based on this period with the requested minutes, not nullpublic Period withSeconds(int seconds)
This method will only affect the seconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
seconds
 the seconds to represent
Period
based on this period with the requested seconds, not nullpublic Period withNanos(long nanos)
This method will only affect the nanoseconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
nanos
 the nanoseconds to represent
Period
based on this period with the requested nanoseconds, not nullpublic Period withDateFieldsOnly()
The returned period will have the same values for the datebased fields (years, months and days) and zero values for the timebased fields.
This instance is immutable and unaffected by this method call.
Period
based on this period with zero values for timebased fields, not nullpublic Period withTimeFieldsOnly()
The returned period will have the same values for the timebased fields (hours, minutes, seconds and nanoseconds) and zero values for the datebased fields.
This instance is immutable and unaffected by this method call.
Period
based on this period with zero values for datebased fields, not nullpublic Period plus(PeriodProvider periodProvider)
This instance is immutable and unaffected by this method call.
periodProvider
 the period to add, not null
Period
based on this period with the requested period added, not null
java.lang.ArithmeticException
 if the capacity of any field is exceededpublic Period plusYears(int years)
This method will only affect the years field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
years
 the years to add, positive or negative
Period
based on this period with the requested years added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusMonths(int months)
This method will only affect the months field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
months
 the months to add, positive or negative
Period
based on this period with the requested months added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusDays(int days)
This method will only affect the days field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
days
 the days to add, positive or negative
Period
based on this period with the requested days added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusHours(int hours)
This method will only affect the hours field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
hours
 the hours to add, positive or negative
Period
based on this period with the requested hours added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusMinutes(int minutes)
This method will only affect the minutes field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
minutes
 the minutes to add, positive or negative
Period
based on this period with the requested minutes added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusSeconds(int seconds)
This method will only affect the seconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
seconds
 the seconds to add, positive or negative
Period
based on this period with the requested seconds added, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period plusNanos(long nanos)
This method will only affect the nanoseconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
nanos
 the nanoseconds to add, positive or negative
Period
based on this period with the requested nanoseconds added, not null
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic Period minus(PeriodProvider periodProvider)
This instance is immutable and unaffected by this method call.
periodProvider
 the period to subtract, not null
Period
based on this period with the requested period subtracted, not null
java.lang.ArithmeticException
 if the capacity of any field is exceededpublic Period minusYears(int years)
This method will only affect the years field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
years
 the years to subtract, positive or negative
Period
based on this period with the requested years subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusMonths(int months)
This method will only affect the months field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
months
 the months to subtract, positive or negative
Period
based on this period with the requested months subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusDays(int days)
This method will only affect the days field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
days
 the days to subtract, positive or negative
Period
based on this period with the requested days subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusHours(int hours)
This method will only affect the hours field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
hours
 the hours to subtract, positive or negative
Period
based on this period with the requested hours subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusMinutes(int minutes)
This method will only affect the minutes field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
minutes
 the minutes to subtract, positive or negative
Period
based on this period with the requested minutes subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusSeconds(int seconds)
This method will only affect the seconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
seconds
 the seconds to subtract, positive or negative
Period
based on this period with the requested seconds subtracted, not null
java.lang.ArithmeticException
 if the capacity of an int
is exceededpublic Period minusNanos(long nanos)
This method will only affect the nanoseconds field. All other fields are left untouched.
This instance is immutable and unaffected by this method call.
nanos
 the nanoseconds to subtract, positive or negative
Period
based on this period with the requested nanoseconds subtracted, not null
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic Period multipliedBy(int scalar)
scalar
 the scalar to multiply by, not null
Period
based on this period with the amounts multiplied by the scalar, not null
java.lang.ArithmeticException
 if the capacity of any field is exceededpublic Period dividedBy(int divisor)
The implementation simply divides each separate field by the divisor using integer division.
divisor
 the value to divide by, not null
Period
based on this period with the amounts divided by the divisor, not null
java.lang.ArithmeticException
 if dividing by zeropublic Period negated()
Period
based on this period with the amounts negated, not null
java.lang.ArithmeticException
 if any field has the minimum valuepublic Period normalized()
Two normalizations occur, one for years and months, and one for
hours, minutes, seconds and nanoseconds.
Days are not normalized, as a day may vary in length at daylight savings cutover.
For example, a period of P1Y15M1DT28H61M
will be normalized to P2Y3M1DT29H1M
.
Note that this method normalizes using ISO8601:
This instance is immutable and unaffected by this method call.
Period
based on this period with the amounts normalized, not null
java.lang.ArithmeticException
 if the capacity of any field is exceededpublic Period normalizedWith24HourDays()
Two normalizations occur, one for years and months, and one for
days, hours, minutes, seconds and nanoseconds.
For example, a period of P1Y15M1DT28H
will be normalized to P2Y3M2DT4H
.
Note that this method normalizes using ISO8601:
This instance is immutable and unaffected by this method call.
Period
based on this period with the amounts normalized, not null
java.lang.ArithmeticException
 if the capacity of any field is exceededpublic long totalYears()
This method ignores days, hours, minutes, seconds and nanos. It calculates using ISO8601:
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic long totalMonths()
This method ignores days, hours, minutes, seconds and nanos. It calculates using ISO8601:
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic long totalDaysWith24HourDays()
This method ignores years and months. It calculates using ISO8601:
public long totalHours()
This method ignores years, months and days. It calculates using ISO8601:
public long totalHoursWith24HourDays()
This method ignores years and months. It calculates using ISO8601:
public long totalMinutes()
This method ignores years, months and days. It calculates using ISO8601:
public long totalMinutesWith24HourDays()
This method ignores years and months. It calculates using ISO8601:
public long totalSeconds()
This method ignores years, months and days. It calculates using ISO8601:
public long totalSecondsWith24HourDays()
This method ignores years and months. It calculates using ISO8601:
public long totalNanos()
This method ignores years, months and days. It calculates using ISO8601:
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic long totalNanosWith24HourDays()
This method ignores years and months. It calculates using ISO8601:
java.lang.ArithmeticException
 if the capacity of a long
is exceededpublic PeriodFields toPeriodFields()
PeriodFields
.
The returned PeriodFields
will only contain the nonzero amounts.
toPeriodFields
in interface PeriodProvider
PeriodFields
equivalent to this period, not nullpublic Duration toEstimatedDuration()
Each PeriodUnit
contains an estimated duration for that unit.
The perunit estimate allows an estimate to be calculated for the whole period
including years, months and days. The estimate will equal the accurate
calculation if the years, months and days fields are zero.
java.lang.ArithmeticException
 if the calculation overflowspublic Duration toDuration()
The calculation uses the hours, minutes, seconds and nanoseconds fields. If years, months or days are present an exception is thrown.
The duration is calculated using ISO8601:
Duration
equivalent to this period, not null
CalendricalException
 if the period cannot be converted as it contains years/months/dayspublic Duration toDurationWith24HourDays()
The calculation uses the days, hours, minutes, seconds and nanoseconds fields. If years or months are present an exception is thrown.
The duration is calculated using ISO8601:
Duration
equivalent to this period, not null
CalendricalException
 if the period cannot be converted as it contains years/months/dayspublic boolean equals(java.lang.Object obj)
The comparison is based on the amounts held in the period.
equals
in class java.lang.Object
obj
 the object to check, null returns false
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
String
, such as P6Y3M1DT12H
.
The output will be in the ISO8601 period format.
toString
in class java.lang.Object


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 