Period (Java SE 26 & JDK 26)
- All Implemented Interfaces:
Serializable, ChronoPeriod, TemporalAmount
-
Field Summary
Fields
A constant for a period of zero.
-
Method Summary
Adds this period to the specified temporal object.
Obtains a
Periodconsisting of the number of years, months, and days between two dates.booleanChecks if this period is equal to another period.
Obtains an instance of
Periodfrom a temporal amount.longGets the value of the requested unit.
Gets the chronology of this period, which is the ISO calendar system.
intgetDays()Gets the amount of days of this period.
intGets the amount of months of this period.
getUnits()Gets the set of units supported by this period.
intgetYears()Gets the amount of years of this period.
inthashCode()A hash code for this period.
booleanChecks if any of the three units of this period are negative.
booleanisZero()Checks if all three units of this period are zero.
Returns a copy of this period with the specified period subtracted.
minusDays(long daysToSubtract) Returns a copy of this period with the specified days subtracted.
minusMonths(long monthsToSubtract) Returns a copy of this period with the specified months subtracted.
minusYears(long yearsToSubtract) Returns a copy of this period with the specified years subtracted.
multipliedBy(int scalar) Returns a new instance with each element in this period multiplied by the specified scalar.
negated()Returns a new instance with each amount in this period negated.
Returns a copy of this period with the years and months normalized.
of(int years, int months, int days) Obtains a
Periodrepresenting a number of years, months and days.ofDays(int days) Obtains a
Periodrepresenting a number of days.ofMonths(int months) Obtains a
Periodrepresenting a number of months.ofWeeks(int weeks) Obtains a
Periodrepresenting a number of weeks.ofYears(int years) Obtains a
Periodrepresenting a number of years.Obtains a
Periodfrom a text string such asPnYnMnD.Returns a copy of this period with the specified period added.
plusDays(long daysToAdd) Returns a copy of this period with the specified days added.
plusMonths(long monthsToAdd) Returns a copy of this period with the specified months added.
plusYears(long yearsToAdd) Returns a copy of this period with the specified years added.
Subtracts this period from the specified temporal object.
toString()Outputs this period as a
String, such asP6Y3M1D.longGets the total number of months in this period.
withDays(int days) Returns a copy of this period with the specified amount of days.
withMonths(int months) Returns a copy of this period with the specified amount of months.
withYears(int years) Returns a copy of this period with the specified amount of years.
Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
ZERO
-
-
Method Details
-
ofYears
-
ofMonths
-
ofWeeks
-
ofDays
-
of
-
from
-
parse
-
between
-
get
-
getUnits
-
getChronology
-
isZero
-
isNegative
-
getYears
-
getMonths
-
getDays
-
withYears
-
withMonths
-
withDays
-
plus
-
plusYears
-
plusMonths
-
plusDays
-
minus
-
minusYears
-
minusMonths
-
minusDays
-
multipliedBy
-
negated
-
normalized
-
toTotalMonths
-
addTo
-
subtractFrom
-
equals
-
hashCode
-
toString
-