A constant for a period of zero.
Obtains a Period
consisting of the number of years, months,
and days between two dates.
Obtains a Period
consisting of the number of years, months,
and days between two dates.
The start date is included, but the end date is not.
The period is calculated by removing complete months, then calculating
the remaining number of days, adjusting to ensure that both have the same sign.
The number of months is then split into years and months based on a 12 month year.
A month is considered if the end day-of-month is greater than or equal to the start day-of-month.
For example, from 2010-01-15
to 2011-03-18
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.
the start date, inclusive, not null
the end date, exclusive, not null
the period between this date and the end date, not null
ChronoLocalDate#until(ChronoLocalDate)
Obtains an instance of Period
from a temporal amount.
Obtains an instance of Period
from a temporal amount.
This obtains a period based on the specified amount.
A TemporalAmount
represents an amount of time, which may be
date-based or time-based, which this factory extracts to a Period
.
The conversion loops around the set of units from the amount and uses
the ChronoUnit#YEARS YEARS
, ChronoUnit#MONTHS MONTHS
and ChronoUnit#DAYS DAYS
units to create a period.
If any other units are found then an exception is thrown.
If the amount is a ChronoPeriod
then it must use the ISO chronology.
the temporal amount to convert, not null
the equivalent period, not null
if the amount of years, months or days exceeds an int
DateTimeExceptionif unable to convert to a { @code Period}
Obtains a Period
representing a number of years, months and days.
Obtains a Period
representing a number of years, months and days.
This creates an instance based on years, months and days.
the amount of years, may be negative
the amount of months, may be negative
the amount of days, may be negative
the period of years, months and days, not null
Obtains a Period
representing a number of days.
Obtains a Period
representing a number of days.
The resulting period will have the specified days. The years and months units will be zero.
the number of days, positive or negative
the period of days, not null
Obtains a Period
representing a number of months.
Obtains a Period
representing a number of months.
The resulting period will have the specified months. The years and days units will be zero.
the number of months, positive or negative
the period of months, not null
Obtains a Period
representing a number of weeks.
Obtains a Period
representing a number of weeks.
The resulting period will have days equal to the weeks multiplied by seven. The years and months units will be zero.
the number of weeks, positive or negative
the period of days, not null
Obtains a Period
representing a number of years.
Obtains a Period
representing a number of years.
The resulting period will have the specified years. The months and days units will be zero.
the number of years, positive or negative
the period of years, not null
Obtains a Period
from a text string such as PnYnMnD
.
Obtains a Period
from a text string such as PnYnMnD
.
This will parse the string produced by toString()
which is
based on the ISO-8601 period formats PnYnMnD
and PnW
.
The string starts with an optional sign, denoted by the ASCII negative
or positive symbol. If negative, the whole period is negated.
The ASCII letter "P" is next in upper or lower case.
There are then four sections, each consisting of a number and a suffix.
At least one of the four sections must be present.
The sections have suffixes in ASCII of "Y", "M", "W" and "D" for
years, months, weeks and days, accepted in upper or lower case.
The suffixes must occur in order.
The number part of each section must consist of ASCII digits.
The number may be prefixed by the ASCII negative or positive symbol.
The number must parse to an int
.
The leading plus/minus sign, and negative values for other units are
not part of the ISO-8601 standard. In addition, ISO-8601 does not
permit mixing between the PnYnMnD
and PnW
formats.
Any week-based input is multiplied by 7 and treated as a number of days.
For example, the following are valid inputs:
"P2Y" -- Period.ofYears(2) "P3M" -- Period.ofMonths(3) "P4W" -- Period.ofWeeks(4) "P5D" -- Period.ofDays(5) "P1Y2M3D" -- Period.of(1, 2, 3) "P1Y2M3W4D" -- Period.of(1, 2, 25) "P-1Y2M" -- Period.of(-1, 2, 0) "-P1Y2M" -- Period.of(-1, -2, 0)
the text to parse, not null
the parsed period, not null
if the text cannot be parsed to a period