A time period is divided into a number of fields, such as hours and seconds. Which fields are supported is defined by the PeriodType class. The default is the standard period type, which supports years, months, weeks, days, hours, minutes, seconds and millis.
When this time period is added to an instant, the effect is of adding each field in turn. As a result, this takes into account daylight savings time. Adding a time period of 1 day to the day before daylight savings starts will only add 23 hours rather than 24 to ensure that the time remains the same. If this is not the behaviour you want, then see {@link Duration}.
The definition of a period also affects the equals method. A period of 1 day is not equal to a period of 24 hours, nor 1 hour equal to 60 minutes. This is because periods represent an abstracted definition of a time period (eg. a day may not actually be 24 hours, it might be 23 or 25 at daylight savings boundary). To compare the actual duration of two periods, convert both to durations using toDuration, an operation that emphasises that the result may differ according to the date you choose.
Period is thread-safe and immutable, provided that the PeriodType is as well. All standard PeriodType classes supplied are thread-safe and immutable. @author Brian S O'Neill @author Stephen Colebourne @since 1.0 @see MutablePeriod
Use a PeriodFormatter to convert a Period to a String.
Periods are immutable. Mutating operations return the new result leaving the original unchanged.
Example:
Period p1 = Period.at(3, WEEK).and(2, DAY).inFuture(); Period p2 = p1.and(12, HOUR);
This is an abstraction of a period of time that supports the concept of an indefinite period. This helps to reduce the amount of special code and values needed to handle indefinite periods which can lead to hard to find errors.
This has an accuracy of milliseconds.
@deprecated Use similar class in com.volantis.openapi.shared.timeThis class models a quantity or amount of time in terms of years, months and days. See {@link Duration} for the time-based equivalent to this class.
Durations and periods differ in their treatment of daylight savings time when added to {@link ZonedDateTime}. A {@code Duration} will add an exactnumber of seconds, thus a duration of one day is always exactly 24 hours. By contrast, a {@code Period} will add a conceptual day, trying to maintainthe local time.
For example, consider adding a period of one day and a duration of one day to 18:00 on the evening before a daylight savings gap. The {@code Period} will addthe conceptual day and result in a {@code ZonedDateTime} at 18:00 the following day.By contrast, the {@code Duration} will add exactly 24 hours, resulting in a{@code ZonedDateTime} at 19:00 the following day (assuming a one hour DST gap).
The supported units of a period are {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} and {@link ChronoUnit#DAYS DAYS}. All three fields are always present, but may be set to zero.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time.
The period is modeled as a directed amount of time, meaning that individual parts of the period may be negative.
This is a value-based class; use of identity-sensitive operations (including reference equality ( {@code ==}), identity hash code, or synchronization) on instances of {@code Period} may have unpredictable results and should be avoided.The {@code equals} method should be used for comparisons. @implSpec This class is immutable and thread-safe. @since 1.8
This is used to represent the human-scale description of an amount of time, known as a period. As an example, "3 months, 4 days and 7 hours" can be stored.
Period stores just six units - years, months, days, hours, minutes and seconds. Certain methods have an implied relationship between some of these units:
Note that beyond the limits specified above, the stored amounts are only descriptive. For example, a year in two calendar systems may differ in length. Only when the period is combined with a date/time in a specific calendar system can the duration of the period be calculated.
Period is immutable and thread-safe. @author Stephen Colebourne
A time period is divided into a number of fields, such as hours and seconds. Which fields are supported is defined by the PeriodType class. The default is the standard period type, which supports years, months, weeks, days, hours, minutes, seconds and millis.
When this time period is added to an instant, the effect is of adding each field in turn. As a result, this takes into account daylight savings time. Adding a time period of 1 day to the day before daylight savings starts will only add 23 hours rather than 24 to ensure that the time remains the same. If this is not the behaviour you want, then see {@link Duration}.
The definition of a period also affects the equals method. A period of 1 day is not equal to a period of 24 hours, nor 1 hour equal to 60 minutes. This is because periods represent an abstracted definition of a time period (eg. a day may not actually be 24 hours, it might be 23 or 25 at daylight savings boundary). To compare the actual duration of two periods, convert both to durations using toDuration, an operation that emphasises that the result may differ according to the date you choose.
Period is thread-safe and immutable, provided that the PeriodType is as well. All standard PeriodType classes supplied are thread-safe and immutable. @author Brian S O'Neill @author Stephen Colebourne @since 1.0 @see MutablePeriod
A time period is divided into a number of fields, such as hours and seconds. Which fields are supported is defined by the PeriodType class. The default is the standard period type, which supports years, months, weeks, days, hours, minutes, seconds and millis.
When this time period is added to an instant, the effect is of adding each field in turn. As a result, this takes into account daylight savings time. Adding a time period of 1 day to the day before daylight savings starts will only add 23 hours rather than 24 to ensure that the time remains the same. If this is not the behaviour you want, then see {@link Duration}.
The definition of a period also affects the equals method. A period of 1 day is not equal to a period of 24 hours, nor 1 hour equal to 60 minutes. This is because periods represent an abstracted definition of a time period (eg. a day may not actually be 24 hours, it might be 23 or 25 at daylight savings boundary). To compare the actual duration of two periods, convert both to durations using toDuration, an operation that emphasises that the result may differ according to the date you choose.
Period is thread-safe and immutable, provided that the PeriodType is as well. All standard PeriodType classes supplied are thread-safe and immutable. @author Brian S O'Neill @author Stephen Colebourne @since 1.0 @see MutablePeriod
This class models a quantity or amount of time in terms of years, months and days. See {@link Duration} for the time-based equivalent to this class.
Durations and period differ in their treatment of daylight savings time when added to {@link ZonedDateTime}. A {@code Duration} will add an exactnumber of seconds, thus a duration of one day is always exactly 24 hours. By contrast, a {@code Period} will add a conceptual day, trying to maintainthe local time.
For example, consider adding a period of one day and a duration of one day to 18:00 on the evening before a daylight savings gap. The {@code Period} will addthe conceptual day and result in a {@code ZonedDateTime} at 18:00 the following day.By contrast, the {@code Duration} will add exactly 24 hours, resulting in a{@code ZonedDateTime} at 19:00 the following day (assuming a one hour DST gap).
The supported units of a period are {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} and {@link ChronoUnit#DAYS DAYS}. All three fields are always present, but may be set to zero.
The period may be used with any calendar system. The meaning of a "year" or "month" is only applied when the object is added to a date.
The period is modeled as a directed amount of time, meaning that individual parts of the period may be negative.
The months and years fields may be {@linkplain #normalized() normalized}. The normalization assumes a 12 month year, so is not appropriate for all calendar systems.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|