Period
The Period
class is designed to represent a time-based duration, typically measured in seconds and nanoseconds. It offers a range of static methods for creating durations based on days, hours, minutes, seconds, milliseconds, and nanoseconds. Additionally, it provides conversion methods to express the duration in various units, as well as the ability to calculate the duration between two temporal objects. This class is ideal for measuring time spans, tracking elapsed time, and performing time-based calculations in applications.
Static Methods
ofDays(days: Integer)
ofDays(days: Integer)
Obtains a
Period
representing a number of standard 24-hour days.Example Usage:
ofMonths(months: Integer)
ofMonths(months: Integer)
Obtains a
Period
representing a number of standard months.Example Usage:
ofYears(years: Integer)
ofYears(years: Integer)
Obtains a
Period
representing a number of standard years.Example Usage:
ofWeeks(weeks: Long)
ofWeeks(weeks: Long)
Obtains a
Period
representing a number of weeks.Example Usage:
parse(text: String)
parse(text: String)
Obtains a
Period
from a text string such asP2Y3M4D
.Parses a textual representation of a period.
Example Usage:
between(startInclusive: LocalDate, endExclusive: LocalDate)
between(startInclusive: LocalDate, endExclusive: LocalDate)
Obtains a
Period
representing the duration between two temporal objects.Example Usage:
Last updated
Was this helpful?