Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package threeten
    Definition Classes
    org
  • package bp

    The main API for dates, times, instants, and durations.

    The main API for dates, times, instants, and durations.

    The classes defined here represent the principal date-time concepts, including instants, durations, dates, times, time-zones and periods. They are based on the ISO calendar system, which is the de facto world calendar following the proleptic Gregorian rules. All the classes are immutable and thread-safe.

    Each date time instance is composed of fields that are conveniently made available by the APIs. For lower level access to the fields refer to the org.threeten.bp.temporal package. Each class includes support for printing and parsing all manner of dates and times. Refer to the org.threeten.bp.format package for customization options.

    The org.threeten.bp.chrono package contains the calendar neutral API. This is intended for use by applications that need to use localized calendars. It is recommended that applications use the ISO-8601 dates and time classes from this package across system boundaries, such as to the database or across the network. The calendar neutral API should be reserved for interactions with users.

    Dates and Times

    org.threeten.bp.Instant is essentially a numeric timestamp. The current Instant can be retrieved from a org.threeten.bp.Clock. This is useful for logging and persistence of a point in time and has in the past been associated with storing the result from java.lang.System#currentTimeMillis().

    org.threeten.bp.LocalDate stores a date without a time. This stores a date like '2010-12-03' and could be used to store a birthday.

    org.threeten.bp.LocalTime stores a time without a date. This stores a time like '11:30' and could be used to store an opening or closing time.

    org.threeten.bp.LocalDateTime stores a date and time. This stores a date-time like '2010-12-03T11:30'.

    org.threeten.bp.OffsetTime stores a time and offset from UTC without a date. This stores a date like '11:30+01:00'. The ZoneOffset is of the form '+01:00'.

    org.threeten.bp.OffsetDateTime stores a date and time and offset from UTC. This stores a date-time like '2010-12-03T11:30+01:00'. This is sometimes found in XML messages and other forms of persistence, but contains less information than a full time-zone.

    org.threeten.bp.ZonedDateTime stores a date and time with a time-zone. This is useful if you want to perform accurate calculations of dates and times taking into account the org.threeten.bp.ZoneId, such as 'Europe/Paris'. Where possible, it is recommended to use a simpler class. The widespread use of time-zones tends to add considerable complexity to an application.

    Duration and Period

    Beyond dates and times, the API also allows the storage of period and durations of time. A org.threeten.bp.Duration is a simple measure of time along the time-line in nanoseconds. A org.threeten.bp.Period expresses an amount of time in units meaningful to humans, such as years or hours.

    Additional value types

    org.threeten.bp.Year stores a year on its own. This stores a single year in isolation, such as '2010'.

    org.threeten.bp.YearMonth stores a year and month without a day or time. This stores a year and month, such as '2010-12' and could be used for a credit card expiry.

    org.threeten.bp.MonthDay stores a month and day without a year or time. This stores a month and day-of-month, such as '--12-03' and could be used to store an annual event like a birthday without storing the year.

    org.threeten.bp.Month stores a month on its own. This stores a single month-of-year in isolation, such as 'DECEMBER'.

    org.threeten.bp.DayOfWeek stores a day-of-week on its own. This stores a single day-of-week in isolation, such as 'TUESDAY'.

    Definition Classes
    threeten
  • package chrono

    Support for calendar systems other than the default ISO.

    Support for calendar systems other than the default ISO.

    The main API is based around the calendar system defined in ISO-8601. This package provides support for alternate systems.

    The supported calendar systems includes:

    -Hijrah calendar -Japanese calendar -Minguo calendar -Thai Buddhist calendar

    It is intended that applications use the main API whenever possible, including code to read and write from a persistent data store, such as a database, and to send dates and times across a network. This package is then used at the user interface level to deal with localized input/output. See ChronoLocalDate for a full discussion of the issues.

    Example

    This example creates and uses a date in a non-ISO calendar system.

            // Print the Thai Buddhist date
            ChronoLocalDate now1 = ThaiBuddhistChronology.INSTANCE.now();
            int day = now1.get(ChronoField.DAY_OF_MONTH);
            int dow = now1.get(ChronoField.DAY_OF_WEEK);
            int month = now1.get(ChronoField.MONTH_OF_YEAR);
            int year = now1.get(ChronoField.YEAR);
            System.out.printf("  Today is %s %s %d-%s-%d%n", now1.getChronology().getId(),
                    dow, day, month, year);
    
            // Enumerate the list of available calendars and print today for each
            Set<String> names = Chronology.getAvailableIds();
            for (String name : names) {
                Chronology<?> chrono = Chronology.of(name);
                ChronoLocalDate<?> date = chrono.now();
                System.out.printf("   %20s: %s%n", chrono.getId(), date.toString());
            }
    
            // Print today's date and the last day of the year for the Thai Buddhist Calendar.
            ChronoLocalDate first = now1
                    .with(ChronoField.DAY_OF_MONTH, 1)
                    .with(ChronoField.MONTH_OF_YEAR, 1);
            ChronoLocalDate last = first
                    .plus(1, ChronoUnit.YEARS)
                    .minus(1, ChronoUnit.DAYS);
            System.out.printf("  %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(),
                    first, last);
    

    Definition Classes
    bp
  • package format

    Provides classes to print and parse dates and times.

    Provides classes to print and parse dates and times.

    Printing and parsing is based around the DateTimeFormatter class. That class contains common formatters and factory methods. The DateTimeFormatterBuilder class is available for advanced and complex use cases.

    Localization occurs by calling withLocale(Locale) on the formatter. Further customization is possible using DecimalStyle.

    Definition Classes
    bp
  • package temporal

    Access to date and time using fields and units.

    Access to date and time using fields and units.

    This package expands on the base package to provide additional functionality for more powerful use cases. Support is included for:

    • Units of date-time, such as years, months, days and hours
    • Fields of date-time, such as month-of-year, day-of-week or hour-of-day
    • Date-time adjustment functions
    • Different definitions of weeks

    Fields and Units

    Dates and times are expressed in terms of fields and units. A unit is used to measure an amount of time, such as years, days or minutes. All units implement org.threeten.bp.temporal.TemporalUnit. The set of well known units is defined in org.threeten.bp.temporal.ChronoUnit, for example, org.threeten.bp.temporal.ChronoUnit#DAYS. The unit interface is designed to allow applications to add their own units.

    A field is used to express part of a larger date-time, such as year, month-of-year or second-of-minute. All fields implement org.threeten.bp.temporal.TemporalField. The set of well known fields are defined in org.threeten.bp.temporal.ChronoField, for example, org.threeten.bp.temporal.ChronoField#HOUR_OF_DAY. An additional fields are defined by org.threeten.bp.temporal.JulianFields. The field interface is designed to allow applications to add their own fields.

    This package provides tools that allow the units and fields of date and time to be accessed in a general way most suited for frameworks. org.threeten.bp.temporal.Temporal provides the abstraction for date time types that support fields. Its methods support getting the value of a field, creating a new date time with the value of a field modified, and extracting another date time type, typically used to extract the offset or time-zone.

    One use of fields in application code is to retrieve fields for which there is no convenience method. For example, getting the day-of-month is common enough that there is a method on LocalDate called getDayOfMonth(). However for more unusual fields it is necessary to use the field. For example, date.get(ChronoField.ALIGNED_WEEK_OF_MONTH). The fields also provide access to the range of valid values.

    Adjustment

    A key part of the date-time problem space is adjusting a date to a new, related value, such as the "last day of the month", or "next Wednesday". These are modeled as functions that adjust a base date-time. The functions implement org.threeten.bp.temporal.TemporalAdjuster and operate on org.threeten.bp.temporal.Temporal. A set of common functions are provided in org.threeten.bp.temporal.TemporalAdjusters. For example, to find the first occurrence of a day-of-week after a given date, use org.threeten.bp.temporal.TemporalAdjusters#next(DayOfWeek), such as date.with(next(MONDAY)).

    Weeks

    Different locales have different definitions of the week. For example, in Europe the week typically starts on a Monday, while in the US it starts on a Sunday. The org.threeten.bp.temporal.WeekFields class models this distinction.

    The ISO calendar system defines an additional week-based division of years. This defines a year based on whole Monday to Monday weeks. This is modeled in org.threeten.bp.temporal.IsoFields.

    Definition Classes
    bp
  • package zone

    Support for time-zones and their rules.

    Support for time-zones and their rules.

    Daylight Saving Time and Time-Zones are concepts used by Governments to alter local time. This package provides support for time-zones, their rules and the resulting gaps and overlaps in the local time-line typically caused by Daylight Saving Time.

    Definition Classes
    bp
  • Clock
  • DateTimeException
  • DateTimeUtils
  • DayOfWeek
  • Duration
  • Instant
  • LocalDate
  • LocalDateTime
  • LocalTime
  • Month
  • MonthDay
  • OffsetDateTime
  • OffsetTime
  • Period
  • Ser
  • Year
  • YearMonth
  • ZoneId
  • ZoneOffset
  • ZoneRegion
  • ZonedDateTime

final class Period extends ChronoPeriod with Serializable

A date-based amount of time, such as '2 years, 3 months and 4 days'.

This class models a quantity or amount of time in terms of years, months and days. See Duration for the time-based equivalent to this class.

Durations and period differ in their treatment of daylight savings time when added to ZonedDateTime. A Duration will add an exact number of seconds, thus a duration of one day is always exactly 24 hours. By contrast, a Period will add a conceptual day, trying to maintain the 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 Period will add the conceptual day and result in a ZonedDateTime at 18:00 the following day. By contrast, the Duration will add exactly 24 hours, resulting in a ZonedDateTime at 19:00 the following day (assuming a one hour DST gap).

The supported units of a period are YEARS, MONTHS and 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 normalized. The normalization assumes a 12 month year, so is not appropriate for all calendar systems.

Specification for implementors

This class is immutable and thread-safe.

Annotations
@SerialVersionUID()
Linear Supertypes
Serializable, ChronoPeriod, TemporalAmount, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Period
  2. Serializable
  3. ChronoPeriod
  4. TemporalAmount
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addTo(temporal: Temporal): Temporal

    Adds this period to the specified temporal object.

    Adds this period to the specified temporal object.

    This returns a temporal object of the same observable type as the input with this period added.

    In most cases, it is clearer to reverse the calling pattern by using Temporal#plus(TemporalAmount).

    // these two lines are equivalent, but the second approach is recommended
    dateTime = thisPeriod.addTo(dateTime);
    dateTime = dateTime.plus(thisPeriod);
    

    The calculation will add the years, then months, then days. Only non-zero amounts will be added. If the date-time has a calendar system with a fixed number of months in a year, then the years and months will be combined before being added.

    This instance is immutable and unaffected by this method call.

    temporal

    the temporal object to adjust, not null

    returns

    an object of the same type with the adjustment made, not null

    Definition Classes
    PeriodChronoPeriodTemporalAmount
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

    DateTimeException if unable to add

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(obj: Any): Boolean

    Checks if this period is equal to another period.

    Checks if this period is equal to another period.

    The comparison is based on the amounts held in the period. To be equal, the years, months and days units must be individually equal. Note that this means that a period of "15 Months" is not equal to a period of "1 Year and 3 Months".

    obj

    the object to check, null returns false

    returns

    true if this is equal to the other period

    Definition Classes
    PeriodChronoPeriod → AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def get(unit: TemporalUnit): Long

    Gets the value of the requested unit.

    Gets the value of the requested unit.

    The supported units are chronology specific. They will typically be YEARS, MONTHS and DAYS. Requesting an unsupported unit will throw an exception.

    unit

    the { @code TemporalUnit} for which to return the value

    returns

    the long value of the unit

    Definition Classes
    PeriodChronoPeriodTemporalAmount
    Exceptions thrown

    DateTimeException if the unit is not supported

    UnsupportedTemporalTypeException if the unit is not supported

  11. def getChronology: Chronology

    Gets the chronology that defines the meaning of the supported units.

    Gets the chronology that defines the meaning of the supported units.

    The period is defined by the chronology. It controls the supported units and restricts addition/subtraction to ChronoLocalDate instances of the same chronology.

    returns

    the chronology defining the period, not null

    Definition Classes
    PeriodChronoPeriod
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def getDays: Int

    Gets the amount of days of this period.

    Gets the amount of days of this period.

    This returns the days unit.

    returns

    the amount of days of this period, may be negative

  14. def getMonths: Int

    Gets the amount of months of this period.

    Gets the amount of months of this period.

    This returns the months unit.

    The months unit is not normalized with the years unit. This means that a period of "15 months" is different to a period of "1 year and 3 months".

    returns

    the amount of months of this period, may be negative

  15. def getUnits: List[TemporalUnit]

    Gets the set of units supported by this period.

    Gets the set of units supported by this period.

    The supported units are chronology specific. They will typically be YEARS, MONTHS and DAYS. They are returned in order from largest to smallest.

    This set can be used in conjunction with #get(TemporalUnit) to access the entire state of the period.

    returns

    a list containing the supported units, not null

    Definition Classes
    PeriodChronoPeriodTemporalAmount
  16. def getYears: Int

    Gets the amount of years of this period.

    Gets the amount of years of this period.

    This returns the years unit.

    The months unit is not normalized with the years unit. This means that a period of "15 months" is different to a period of "1 year and 3 months".

    returns

    the amount of years of this period, may be negative

  17. def hashCode: Int

    A hash code for this period.

    A hash code for this period.

    returns

    a suitable hash code

    Definition Classes
    PeriodChronoPeriod → AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. def isNegative: Boolean

    Checks if any of the three units of this period are negative.

    Checks if any of the three units of this period are negative.

    This checks whether the years, months or days units are less than zero.

    returns

    true if any unit of this period is negative

    Definition Classes
    PeriodChronoPeriod
  20. def isZero: Boolean

    Checks if all three units of this period are zero.

    Checks if all three units of this period are zero.

    A zero period has the value zero for the years, months and days units.

    returns

    true if this period is zero-length

    Definition Classes
    PeriodChronoPeriod
  21. def minus(amountToSubtract: TemporalAmount): Period

    Returns a copy of this period with the specified amount subtracted.

    Returns a copy of this period with the specified amount subtracted.

    This input amount is converted to a Period using from(TemporalAmount). This operates separately on the years, months and days.

    For example, "1 year, 6 months and 3 days" minus "2 years, 2 months and 2 days" returns "-1 years, 4 months and 1 day".

    This instance is immutable and unaffected by this method call.

    amountToSubtract

    the period to subtract, not null

    returns

    a { @code Period} based on this period with the requested period subtracted, not null

    Definition Classes
    PeriodChronoPeriod
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  22. def minusDays(daysToSubtract: Long): Period

    Returns a copy of this period with the specified days subtracted.

    Returns a copy of this period with the specified days subtracted.

    This subtracts the amount from the days unit in a copy of this period. The years and months units are unaffected. For example, "1 year, 6 months and 3 days" minus 2 days returns "1 year, 6 months and 1 day".

    This instance is immutable and unaffected by this method call.

    daysToSubtract

    the months to subtract, positive or negative

    returns

    a { @code Period} based on this period with the specified days subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  23. def minusMonths(monthsToSubtract: Long): Period

    Returns a copy of this period with the specified months subtracted.

    Returns a copy of this period with the specified months subtracted.

    This subtracts the amount from the months unit in a copy of this period. The years and days units are unaffected. For example, "1 year, 6 months and 3 days" minus 2 months returns "1 year, 4 months and 3 days".

    This instance is immutable and unaffected by this method call.

    monthsToSubtract

    the years to subtract, positive or negative

    returns

    a { @code Period} based on this period with the specified months subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  24. def minusYears(yearsToSubtract: Long): Period

    Returns a copy of this period with the specified years subtracted.

    Returns a copy of this period with the specified years subtracted.

    This subtracts the amount from the years unit in a copy of this period. The months and days units are unaffected. For example, "1 year, 6 months and 3 days" minus 2 years returns "-1 years, 6 months and 3 days".

    This instance is immutable and unaffected by this method call.

    yearsToSubtract

    the years to subtract, positive or negative

    returns

    a { @code Period} based on this period with the specified years subtracted, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  25. def multipliedBy(scalar: Int): Period

    Returns a new instance with each element in this period multiplied by the specified scalar.

    Returns a new instance with each element in this period multiplied by the specified scalar.

    This simply multiplies each field, years, months, days and normalized time, by the scalar. No normalization is performed.

    scalar

    the scalar to multiply by, not null

    returns

    a { @code Period} based on this period with the amounts multiplied by the scalar, not null

    Definition Classes
    PeriodChronoPeriod
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. def negated: Period

    Returns a new instance with each amount in this period negated.

    Returns a new instance with each amount in this period negated.

    returns

    a { @code Period} based on this period with the amounts negated, not null

    Definition Classes
    PeriodChronoPeriod
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  28. def normalized: Period

    Returns a copy of this period with the years and months normalized using a 12 month year.

    Returns a copy of this period with the years and months normalized using a 12 month year.

    This normalizes the years and months units, leaving the days unit unchanged. The months unit is adjusted to have an absolute value less than 11, with the years unit being adjusted to compensate. For example, a period of "1 Year and 15 months" will be normalized to "2 years and 3 months".

    The sign of the years and months units will be the same after normalization. For example, a period of "1 year and -25 months" will be normalized to "-1 year and -1 month".

    This normalization uses a 12 month year which is not valid for all calendar systems.

    This instance is immutable and unaffected by this method call.

    returns

    a { @code Period} based on this period with excess months normalized to years, not null

    Definition Classes
    PeriodChronoPeriod
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  29. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  30. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  31. def plus(amountToAdd: TemporalAmount): Period

    Returns a copy of this period with the specified amount added.

    Returns a copy of this period with the specified amount added.

    This input amount is converted to a Period using from(TemporalAmount). This operates separately on the years, months and days.

    For example, "1 year, 6 months and 3 days" plus "2 years, 2 months and 2 days" returns "3 years, 8 months and 5 days".

    This instance is immutable and unaffected by this method call.

    amountToAdd

    the period to add, not null

    returns

    a { @code Period} based on this period with the requested period added, not null

    Definition Classes
    PeriodChronoPeriod
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  32. def plusDays(daysToAdd: Long): Period

    Returns a copy of this period with the specified days added.

    Returns a copy of this period with the specified days added.

    This adds the amount to the days unit in a copy of this period. The years and months units are unaffected. For example, "1 year, 6 months and 3 days" plus 2 days returns "1 year, 6 months and 5 days".

    This instance is immutable and unaffected by this method call.

    daysToAdd

    the days to add, positive or negative

    returns

    a { @code Period} based on this period with the specified days added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  33. def plusMonths(monthsToAdd: Long): Period

    Returns a copy of this period with the specified months added.

    Returns a copy of this period with the specified months added.

    This adds the amount to the months unit in a copy of this period. The years and days units are unaffected. For example, "1 year, 6 months and 3 days" plus 2 months returns "1 year, 8 months and 3 days".

    This instance is immutable and unaffected by this method call.

    monthsToAdd

    the months to add, positive or negative

    returns

    a { @code Period} based on this period with the specified months added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  34. def plusYears(yearsToAdd: Long): Period

    Returns a copy of this period with the specified years added.

    Returns a copy of this period with the specified years added.

    This adds the amount to the years unit in a copy of this period. The months and days units are unaffected. For example, "1 year, 6 months and 3 days" plus 2 years returns "3 years, 6 months and 3 days".

    This instance is immutable and unaffected by this method call.

    yearsToAdd

    the years to add, positive or negative

    returns

    a { @code Period} based on this period with the specified years added, not null

    Exceptions thrown

    ArithmeticException if numeric overflow occurs

  35. def subtractFrom(temporal: Temporal): Temporal

    Subtracts this period from the specified temporal object.

    Subtracts this period from the specified temporal object.

    This returns a temporal object of the same observable type as the input with this period subtracted.

    In most cases, it is clearer to reverse the calling pattern by using Temporal#minus(TemporalAmount).

    // these two lines are equivalent, but the second approach is recommended
    dateTime = thisPeriod.subtractFrom(dateTime);
    dateTime = dateTime.minus(thisPeriod);
    

    The calculation operates as follows. First, the chronology of the temporal is checked to ensure it is ISO chronology or null. Second, if the months are zero, the years are added if non-zero, otherwise the combination of years and months is added if non-zero. Finally, any days are added.

    The calculation will subtract the years, then months, then days. Only non-zero amounts will be subtracted. If the date-time has a calendar system with a fixed number of months in a year, then the years and months will be combined before being subtracted.

    This instance is immutable and unaffected by this method call.

    temporal

    the temporal object to adjust, not null

    returns

    an object of the same type with the adjustment made, not null

    Definition Classes
    PeriodChronoPeriodTemporalAmount
    Exceptions thrown

    ArithmeticException if numeric overflow occurs

    DateTimeException if unable to subtract

  36. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  37. def toString: String

    Outputs this period as a String, such as P6Y3M1D.

    Outputs this period as a String, such as P6Y3M1D.

    The output will be in the ISO-8601 period format. A zero period will be represented as zero days, 'P0D'.

    returns

    a string representation of this period, not null

    Definition Classes
    PeriodChronoPeriod → AnyRef → Any
  38. def toTotalMonths: Long

    Gets the total number of months in this period using a 12 month year.

    Gets the total number of months in this period using a 12 month year.

    This returns the total number of months in the period by multiplying the number of years by 12 and adding the number of months.

    This uses a 12 month year which is not valid for all calendar systems.

    This instance is immutable and unaffected by this method call.

    returns

    the total number of months in the period, may be negative

  39. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  42. def withDays(days: Int): Period

    Returns a copy of this period with the specified amount of days.

    Returns a copy of this period with the specified amount of days.

    This sets the amount of the days unit in a copy of this period. The years and months units are unaffected.

    This instance is immutable and unaffected by this method call.

    days

    the days to represent, may be negative

    returns

    a { @code Period} based on this period with the requested days, not null

  43. def withMonths(months: Int): Period

    Returns a copy of this period with the specified amount of months.

    Returns a copy of this period with the specified amount of months.

    This sets the amount of the months unit in a copy of this period. The years and days units are unaffected.

    The months unit is not normalized with the years unit. This means that a period of "15 months" is different to a period of "1 year and 3 months".

    This instance is immutable and unaffected by this method call.

    months

    the months to represent, may be negative

    returns

    a { @code Period} based on this period with the requested months, not null

  44. def withYears(years: Int): Period

    Returns a copy of this period with the specified amount of years.

    Returns a copy of this period with the specified amount of years.

    This sets the amount of the years unit in a copy of this period. The months and days units are unaffected.

    The months unit is not normalized with the years unit. This means that a period of "15 months" is different to a period of "1 year and 3 months".

    This instance is immutable and unaffected by this method call.

    years

    the years to represent, may be negative

    returns

    a { @code Period} based on this period with the requested years, not null

Inherited from Serializable

Inherited from ChronoPeriod

Inherited from TemporalAmount

Inherited from AnyRef

Inherited from Any

Ungrouped