This date operates using a given Accounting calendar.
An Accounting calendar differs greatly from the ISO calendar.
The start of the Accounting calendar will vary against the ISO calendar.
Depending on options chosen, it can start as early as 0000-01-26 (ISO) or as late as 0001-01-04 (ISO).
This class must be treated as a value type. Do not synchronize, rely on the identity hash code or use the distinction between equals() and ==.
| Modifier and Type | Field and Description |
|---|---|
| private final AccountingChronology | chronology
The chronology for manipulating this date. |
| private final short | day
The day. |
| private static final int | DAYS_IN_WEEK
Number of days in a week. |
| private static final int | DAYS_PER_LONG_CYCLE
Number of days in a long (400-year) cycle. |
| private final short | month
The month (period). |
| private final int | prolepticYear
The proleptic year. |
| private static final long | serialVersionUID
Serialization version. |
| private static final int | WEEKS_IN_YEAR
Number of weeks in a regular (non-leap) year. |
| Access | Constructor and Description |
|---|---|
| private | AccountingDate(AccountingChronology
the Accounting chronology to base the date on, not null chronology, int the Accounting proleptic-year prolepticYear, int the Accounting month (period), from 1 to 12 or 1 to 13 month, int the Accounting day-of-month, from 1 to 35 or 1 to 42 dayOfMonth)Creates an instance from validated data. |
| Modifier and Type | Method and Description |
|---|---|
| public ChronoLocalDateTime | atTime(LocalTime
the local time to use, not null localTime)Overrides default java. Combines this date with a time to create a |
| pack-priv static AccountingDate | Returns: the date in Accounting calendar system, not nullthe Accounting chronology to base the date on, not null chronology, int the Accounting proleptic-year prolepticYear, int month, int dayOfMonth)Creates an |
| public boolean | Returns: true if this is equal to the other datethe object to check, null returns false obj)Overrides org. Implements java. Compares this date to another date, including the chronology. |
| public static AccountingDate | Returns: the date in Accounting calendar system, not nullthe Accounting chronology to base the date on, not null chronology, TemporalAccessor the temporal object to convert, not null temporal)Obtains an |
| public AccountingChronology | Returns: the Accounting chronology, not nullImplements java. Gets the chronology of this date, which is an Accounting calendar system. |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| public int | Returns: a suitable hash code based only on the Chronology and the dateOverrides org. Implements java. A hash code for this date. |
| private static int | |
| public int | lengthOfMonth()
Implements java. Returns the length of the month represented by this date, as defined by the calendar system. |
| public int | lengthOfYear()
Overrides default java. Returns the length of the year represented by this date, as defined by the calendar system. |
| pack-priv int | |
| public AccountingDate | minus(TemporalAmount
the amount to subtract, not null amount)Overrides default java. Returns an object of the same type as this object with an amount subtracted. |
| public AccountingDate | minus(long
the amount of the specified unit to subtract, may be negative amountToSubtract, TemporalUnit the unit of the amount to subtract, not null unit)Overrides default java. Returns an object of the same type as this object with the specified period subtracted. |
| public static AccountingDate | Returns: the current date using the system clock and default time-zone, not nullthe Accounting chronology to base the date on, not null chronology)Obtains the current |
| public static AccountingDate | Returns: the current date using the system clock, not nullthe Accounting chronology to base the date on, not null chronology, ZoneId the zone ID to use, not null zone)Obtains the current |
| public static AccountingDate | Returns: the current date, not nullthe Accounting chronology to base the date on, not null chronology, Clock the clock to use, not null clock)Obtains the current |
| public static AccountingDate | Returns: the date in the given Accounting calendar system, not nullthe Accounting chronology to base the date on, not null chronology, int the Accounting proleptic-year prolepticYear, int the Accounting month-of-year, from 1 to 12 or 1 to 13 month, int the Accounting day-of-month, from 1 to 35 or 1 to 42 dayOfMonth)Obtains a |
| pack-priv static AccountingDate | Returns: the date in given Accounting calendar system, not nullthe Accounting chronology to base the date on, not null chronology, long the epoch day to convert based on 1970-01-01 (ISO) epochDay)Obtains an |
| pack-priv static AccountingDate | Returns: the date in Accounting calendar system, not nullthe Accounting chronology to base the date on, not null chronology, int the Accounting proleptic-year prolepticYear, int the Accounting day-of-year, from 1 to 371 dayOfYear)Obtains an |
| public AccountingDate | plus(TemporalAmount
the amount to add, not null amount)Overrides default java. Returns an object of the same type as this object with an amount added. |
| public AccountingDate | plus(long
the amount of the specified unit to add, may be negative amountToAdd, TemporalUnit the unit of the amount to add, not null unit)Overrides org. Overrides default java. Returns an object of the same type as this object with the specified period added. |
| pack-priv ValueRange | rangeAlignedWeekOfMonth()
Implements abstract org.
|
| private Object | |
| pack-priv AccountingDate | resolvePrevious(int newYear, int newMonth, int dayOfMonth)
Implements abstract org.
|
| private static AccountingDate | |
| public long | toEpochDay()
Overrides default java. Converts this date to the Epoch Day. |
| public long | until(Temporal
the end date, exclusive, which is converted to a
endExclusive, TemporalUnit ChronoLocalDate in the same chronology, not nullthe unit to measure the amount in, not null unit)Implements java. Calculates the amount of time until another date in terms of the specified unit. |
| public ChronoPeriod | until(ChronoLocalDate
the end date, exclusive, which may be in any chronology, not null endDateExclusive)Implements java. Calculates the period between this date and another date as a |
| public AccountingDate | with(TemporalAdjuster
the adjuster to use, not null adjuster)Overrides default java. Returns an adjusted object of the same type as this object with the adjustment made. |
| public AccountingDate | with(TemporalField
the field to set in the result, not null field, long the new value of the field in the result newValue)Overrides org. Overrides default java. Returns an object of the same type as this object with the specified field altered. |
| pack-priv AbstractDate |
| chronology | back to summary |
|---|---|
| private final AccountingChronology chronology The chronology for manipulating this date. | |
| day | back to summary |
|---|---|
| private final short day The day. | |
| DAYS_IN_WEEK | back to summary |
|---|---|
| private static final int DAYS_IN_WEEK Number of days in a week. | |
| DAYS_PER_LONG_CYCLE | back to summary |
|---|---|
| private static final int DAYS_PER_LONG_CYCLE Number of days in a long (400-year) cycle. | |
| month | back to summary |
|---|---|
| private final short month The month (period). | |
| prolepticYear | back to summary |
|---|---|
| private final int prolepticYear The proleptic year. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| WEEKS_IN_YEAR | back to summary |
|---|---|
| private static final int WEEKS_IN_YEAR Number of weeks in a regular (non-leap) year. | |
| AccountingDate | back to summary |
|---|---|
| private AccountingDate(AccountingChronology chronology, int prolepticYear, int month, int dayOfMonth) Creates an instance from validated data.
| |
| atTime | back to summary |
|---|---|
| public ChronoLocalDateTime Overrides default java. Doc from java. Combines this date with a time to create a
This returns a
| |
| create | back to summary |
|---|---|
| pack-priv static AccountingDate create(AccountingChronology chronology, int prolepticYear, int month, int dayOfMonth) Creates an
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides org. Implements java. Compares this date to another date, including the chronology. Compares this date with another ensuring that the date is the same.
Only objects of this concrete type are compared, other types return false.
To compare the dates of two | |
| from | back to summary |
|---|---|
| public static AccountingDate from(AccountingChronology chronology, TemporalAccessor temporal) Obtains an
This obtains a date in the specified Accounting calendar system based on the specified temporal.
A
The conversion typically uses the
This method almost matches the signature of the functional interface
| |
| getChronology | back to summary |
|---|---|
| public AccountingChronology getChronology() Implements java. Gets the chronology of this date, which is an Accounting calendar system.
The
| |
| getDayOfMonth | back to summary |
|---|---|
| pack-priv int getDayOfMonth() Implements abstract org.
| |
| getDayOfYear | back to summary |
|---|---|
| pack-priv int getDayOfYear() Implements abstract org.
| |
| getMonth | back to summary |
|---|---|
| pack-priv int getMonth() Implements abstract org.
| |
| getProlepticYear | back to summary |
|---|---|
| pack-priv int getProlepticYear() Implements abstract org.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Implements java. A hash code for this date.
| |
| lengthOfMonth | back to summary |
|---|---|
| private static int lengthOfMonth(AccountingChronology chronology, int prolepticYear, int month) | |
| lengthOfMonth | back to summary |
|---|---|
| public int lengthOfMonth() Implements java. Doc from java. Returns the length of the month represented by this date, as defined by the calendar system. This returns the length of the month in days.
| |
| lengthOfYear | back to summary |
|---|---|
| public int lengthOfYear() Overrides default java. Doc from java. Returns the length of the year represented by this date, as defined by the calendar system. This returns the length of the year in days.
The default implementation uses
| |
| lengthOfYearInMonths | back to summary |
|---|---|
| pack-priv int lengthOfYearInMonths() Overrides org.
| |
| minus | back to summary |
|---|---|
| public AccountingDate minus(TemporalAmount amount) Overrides default java. Doc from java. Returns an object of the same type as this object with an amount subtracted.
This adjusts this temporal, subtracting according to the rules of the specified amount.
The amount is typically a Some example code indicating how and why this method is used: date = date.minus(period); // subtract a Period instance date = date.minus(duration); // subtract a Duration instance date = date.minus(workingDays(6)); // example user-written workingDays method
Note that calling
| |
| minus | back to summary |
|---|---|
| public AccountingDate minus(long amountToSubtract, TemporalUnit unit) Overrides default java. Doc from java. Returns an object of the same type as this object with the specified period subtracted.
This method returns a new object based on this one with the specified period subtracted.
For example, on a In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st March, then subtracting one month would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
| |
| now | back to summary |
|---|---|
| public static AccountingDate now(AccountingChronology chronology) Obtains the current
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
| |
| now | back to summary |
|---|---|
| public static AccountingDate now(AccountingChronology chronology, ZoneId zone) Obtains the current
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
| |
| now | back to summary |
|---|---|
| public static AccountingDate now(AccountingChronology chronology, Clock clock) Obtains the current This will query the specified clock to obtain the current date - today. Using this method allows the use of an alternate clock for testing. The alternate clock may be introduced using dependency injection.
| |
| of | back to summary |
|---|---|
| public static AccountingDate of(AccountingChronology chronology, int prolepticYear, int month, int dayOfMonth) Obtains a
This returns a
| |
| ofEpochDay | back to summary |
|---|---|
| pack-priv static AccountingDate ofEpochDay(AccountingChronology chronology, long epochDay) Obtains an
| |
| ofYearDay | back to summary |
|---|---|
| pack-priv static AccountingDate ofYearDay(AccountingChronology chronology, int prolepticYear, int dayOfYear) Obtains an
This returns an
| |
| plus | back to summary |
|---|---|
| public AccountingDate plus(TemporalAmount amount) Overrides default java. Doc from java. Returns an object of the same type as this object with an amount added.
This adjusts this temporal, adding according to the rules of the specified amount.
The amount is typically a Some example code indicating how and why this method is used: date = date.plus(period); // add a Period instance date = date.plus(duration); // add a Duration instance date = date.plus(workingDays(6)); // example user-written workingDays method
Note that calling
| |
| plus | back to summary |
|---|---|
| public AccountingDate plus(long amountToAdd, TemporalUnit unit) Overrides org. Overrides default java. Doc from java. Returns an object of the same type as this object with the specified period added.
This method returns a new object based on this one with the specified period added.
For example, on a In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then adding one month would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
| |
| rangeAlignedWeekOfMonth | back to summary |
|---|---|
| pack-priv ValueRange rangeAlignedWeekOfMonth() Implements abstract org.
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() Validates the object.
| |
| resolvePrevious | back to summary |
|---|---|
| pack-priv AccountingDate resolvePrevious(int newYear, int newMonth, int dayOfMonth) Implements abstract org.
| |
| resolvePreviousValid | back to summary |
|---|---|
| private static AccountingDate resolvePreviousValid(AccountingChronology chronology, int prolepticYear, int month, int day) | |
| toEpochDay | back to summary |
|---|---|
| public long toEpochDay() Overrides default java. Doc from java. Converts this date to the Epoch Day.
The
This default implementation queries the
| |
| until | back to summary |
|---|---|
| public long until(Temporal endExclusive, TemporalUnit unit) Implements java. Doc from java. Calculates the amount of time until another date in terms of the specified unit.
This calculates the amount of time between two
There are two equivalent ways of using this method.
The first is to invoke this method.
The second is to use // these two lines are equivalent amount = start.until(end, MONTHS); amount = MONTHS.between(start, end);The choice should be made based on which makes the code more readable.
The calculation is implemented in this method for
If the unit is not a This instance is immutable and unaffected by this method call.
| |
| until | back to summary |
|---|---|
| public ChronoPeriod until(ChronoLocalDate endDateExclusive) Implements java. Doc from java. Calculates the period between this date and another date as a
This calculates the period between two dates. All supplied chronologies
calculate the period using years, months and days, however the
The start and end points are The calculation is performed using the chronology of this date. If necessary, the input date will be converted to match. This instance is immutable and unaffected by this method call.
| |
| with | back to summary |
|---|---|
| public AccountingDate with(TemporalAdjuster adjuster) Overrides default java. Doc from java. Returns an adjusted object of the same type as this object with the adjustment made.
This adjusts this date-time according to the rules of the specified adjuster.
A simple adjuster might simply set the one of the fields, such as the year field.
A more complex adjuster might set the date to the last day of the month.
A selection of common adjustments is provided in
Some example code indicating how and why this method is used: date = date.with(Month.JULY); // most key classes implement TemporalAdjuster date = date.with(lastDayOfMonth()); // static import from Adjusters date = date.with(next(WEDNESDAY)); // static import from Adjusters and DayOfWeek
| |
| with | back to summary |
|---|---|
| public AccountingDate with(TemporalField field, long newValue) Overrides org. Overrides default java. Doc from java. Returns an object of the same type as this object with the specified field altered.
This returns a new object based on this one with the value for the specified field changed.
For example, on a In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then changing the month to February would be unclear. In cases like this, the field is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
| |
| withDayOfYear | back to summary |
|---|---|
| pack-priv AbstractDate withDayOfYear(int value) Overrides org.
| |