Class Symmetry454Chronology
- All Implemented Interfaces:
Serializable,Comparable<Chronology>,Chronology
This chronology defines the rules of the Symmetry454 calendar system.
Dates are aligned such that 0001/01/01 (Sym454) is 0001-01-01 (ISO).
The calendar implemented by this class is proleptic, with January 1st as the start of the year. Each month either has 28 days or 35 days, in an alternating pattern; January has 28 days, February has 35 days and March again has 28 days. Due to this, each quarter consists of 13 weeks.
Normal years thus have 364 days, whereas leap years have an extra week, aptly called leap week, added to the end, extending the year to 371 days.
The fields are defined as follows:
- era - Same eras as used in the Gregorian calendar: 'Before Common Era' (BCE) and 'Common Era' (CE).
- year-of-era - The year-of-era for the current era increases uniformly from the epoch at year 1.
- proleptic-year - The proleptic year is the same as the year-of-era for the current era.
- month-of-year - There are 12 months in an Symmetry454 year, numbered from 1 to 12.
- day-of-month - There are 28 days in a standard Symmetry454 month, numbered from 1 to 28, except for the middle-month in each quarter, which spans 35 days: February, May, August, November; and December in leap years.
- day-of-year - There are 364 days in a standard Symmetry454 year and 371 days in a leap year. The days are numbered accordingly.
- leap-year - Leap years occur every 5 or 6 years, evenly spread over 293 years according the formula: (52 > ((52 * year + 146) % 293)).
- Week day - every month starts on a Monday. There are no days outside of the week or month.
Implementation Requirements
This class is immutable and thread-safe.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe number of days from year zero to CE 1970, still the era only allows CE 1 and higher.static final Symmetry454ChronologySingleton instance for the Symmetry454 chronology. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondate(int prolepticYear, int month, int dayOfMonth) Obtains a local date in Symmetry454 calendar system from the proleptic-year, month-of-year and day-of-month fields.Obtains a local date in Symmetry454 calendar system from the era, year-of-era, month-of-year and day-of-month fields.date(TemporalAccessor temporal) Obtains a Symmetry454 local date from another date-time object.dateEpochDay(long epochDay) Obtains a local date in the Symmetry454 calendar system from the epoch-day.dateNow()Obtains the current Symmetry454 local date from the system clock in the default time-zone.Obtains the current Symmetry454 local date from the specified clock.Obtains the current Symmetry454 local date from the system clock in the specified time-zone.dateYearDay(int prolepticYear, int dayOfYear) Obtains a local date in Symmetry454 calendar system from the proleptic-year and day-of-year fields.dateYearDay(Era era, int yearOfEra, int dayOfYear) Obtains a local date in Symmetry454 calendar system from the era, year-of-era and day-of-year fields.eraOf(int eraValue) Creates the chronology era object from the numeric value.eras()Gets the list of eras for the chronology.Gets the calendar type of the underlying calendar system, which returns null.getId()Gets the ID of the chronology - 'Sym454'.static longgetLeapYearsBefore(long prolepticYear) Get the count of leap years since CE 1.booleanisLeapYear(long year) Checks if the specified year is a leap year.localDateTime(TemporalAccessor temporal) Obtains a Symmetry454 local date-time from another date-time object.intprolepticYear(Era era, int yearOfEra) range(ChronoField field) zonedDateTime(Instant instant, ZoneId zone) Obtains a Symmetry454 zoned date-time in this chronology from anInstant.zonedDateTime(TemporalAccessor temporal) Obtains a Symmetry454 zoned date-time from another date-time object.Methods inherited from class java.time.chrono.AbstractChronology
compareTo, equals, hashCode, resolveDate, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.time.chrono.Chronology
getDisplayName, period
-
Field Details
-
INSTANCE
Singleton instance for the Symmetry454 chronology. -
DAYS_0001_TO_1970
public static final long DAYS_0001_TO_1970The number of days from year zero to CE 1970, still the era only allows CE 1 and higher. There are 6 full 293-year cycles from CE 1 to 1758, with 6 * 52 leap years, i.e. 312. There are 37 leap years from CE 1758 to 1970.- See Also:
-
-
Constructor Details
-
Symmetry454Chronology
Deprecated.Use the singletonINSTANCEinstead.Private constructor, that is public to satisfy theServiceLoader.
-
-
Method Details
-
getId
Gets the ID of the chronology - 'Sym454'.The ID uniquely identifies the
Chronology. It can be used to lookup theChronologyusingChronology.of(String).- Specified by:
getIdin interfaceChronology- Returns:
- the chronology ID - 'Sym454'
- See Also:
-
getCalendarType
Gets the calendar type of the underlying calendar system, which returns null.The Unicode Locale Data Markup Language (LDML) specification does not define an identifier for this calendar system, thus null is returned.
- Specified by:
getCalendarTypein interfaceChronology- Returns:
- the calendar system type, null
- See Also:
-
date
Obtains a local date in Symmetry454 calendar system from the era, year-of-era, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
era- the Symmetry454 era, not nullyearOfEra- the year-of-eramonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aIsoEra
-
date
Obtains a local date in Symmetry454 calendar system from the proleptic-year, month-of-year and day-of-month fields.- Specified by:
datein interfaceChronology- Parameters:
prolepticYear- the proleptic-yearmonth- the month-of-yeardayOfMonth- the day-of-month- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateYearDay
Obtains a local date in Symmetry454 calendar system from the era, year-of-era and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
era- the Symmetry454 era, not nullyearOfEra- the year-of-eradayOfYear- the day-of-year- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the dateClassCastException- if theerais not aIsoEra
-
dateYearDay
Obtains a local date in Symmetry454 calendar system from the proleptic-year and day-of-year fields.- Specified by:
dateYearDayin interfaceChronology- Parameters:
prolepticYear- the proleptic-yeardayOfYear- the day-of-year- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateEpochDay
Obtains a local date in the Symmetry454 calendar system from the epoch-day.- Specified by:
dateEpochDayin interfaceChronology- Parameters:
epochDay- the epoch day- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Symmetry454 local date from the system clock in the default time-zone.This will query the
system clockin the default time-zone to obtain the current date.Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
- Specified by:
dateNowin interfaceChronology- Returns:
- the current Symmetry454 local date using the system clock and default time-zone, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Symmetry454 local date from the system clock in the specified time-zone.This will query the
system clockto obtain the current date. Specifying the time-zone avoids dependence on the default time-zone.Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
- Specified by:
dateNowin interfaceChronology- Parameters:
zone- the zone ID to use, not null- Returns:
- the current Symmetry454 local date using the system clock, not null
- Throws:
DateTimeException- if unable to create the date
-
dateNow
Obtains the current Symmetry454 local date from the specified clock.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.- Specified by:
dateNowin interfaceChronology- Parameters:
clock- the clock to use, not null- Returns:
- the current Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the date
-
date
Obtains a Symmetry454 local date from another date-time object.- Specified by:
datein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Symmetry454 local date, not null
- Throws:
DateTimeException- if unable to create the date
-
localDateTime
Obtains a Symmetry454 local date-time from another date-time object.- Specified by:
localDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Symmetry454 local date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
Obtains a Symmetry454 zoned date-time from another date-time object.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
temporal- the date-time object to convert, not null- Returns:
- the Symmetry454 zoned date-time, not null
- Throws:
DateTimeException- if unable to create the date-time
-
zonedDateTime
Obtains a Symmetry454 zoned date-time in this chronology from anInstant.- Specified by:
zonedDateTimein interfaceChronology- Parameters:
instant- the instant to create the date-time from, not nullzone- the time-zone, not null- Returns:
- the Symmetry454 zoned date-time, not null
- Throws:
DateTimeException- if the result exceeds the supported range
-
isLeapYear
public boolean isLeapYear(long year) Checks if the specified year is a leap year.A leap-year is a year of a longer length than normal. Leap years in the calendar system match those of the ISO calendar system.
- Specified by:
isLeapYearin interfaceChronology- Parameters:
year- the proleptic-year to check, not validated for range- Returns:
- true if the year is a leap year
-
eraOf
Creates the chronology era object from the numeric value.The list of eras is shared with
IsoEra.- Specified by:
eraOfin interfaceChronology- Parameters:
eraValue- the era value- Returns:
- the calendar system era, not null
- Throws:
DateTimeException- if unable to create the era
-
eras
Gets the list of eras for the chronology.The list of eras is shared with
IsoEra.- Specified by:
erasin interfaceChronology- Returns:
- the list of eras for the chronology, may be immutable, not null
-
range
- Specified by:
rangein interfaceChronology
-
prolepticYear
- Specified by:
prolepticYearin interfaceChronology
-
getLeapYearsBefore
public static long getLeapYearsBefore(long prolepticYear) Get the count of leap years since CE 1.- Parameters:
prolepticYear- the year- Returns:
- the number of leap years since CE 1
-
INSTANCEinstead.