Class BritishCutoverChronology

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<java.time.chrono.Chronology>, java.time.chrono.Chronology

    public final class BritishCutoverChronology
    extends java.time.chrono.AbstractChronology
    implements java.io.Serializable
    The British Julian-Gregorian cutover calendar system.

    The British calendar system follows the rules of the Julian calendar until 1752 and the rules of the Gregorian (ISO) calendar since then. The Julian differs from the Gregorian only in terms of the leap year rule.

    The Julian and Gregorian calendar systems are linked to Rome and the Vatican with the Julian preceding the Gregorian. The Gregorian was introduced to handle the drift of the seasons through the year due to the inaccurate Julian leap year rules. When first introduced by the Vatican in 1582, the cutover resulted in a "gap" of 10 days.

    While the calendar was introduced in 1582, it was not adopted everywhere. Britain did not adopt it until the 1752, when Wednesday 2nd September 1752 was followed by Thursday 14th September 1752.

    This chronology implements the proleptic Julian calendar system followed by the proleptic Gregorian calendar system (identical to the ISO calendar system). Dates are aligned such that 0001-01-01 (British) is 0000-12-30 (ISO).

    This class implements a calendar where January 1st is the start of the year. The history of the start of the year is complex and using the current standard is the most consistent.

    The eras of this calendar system are defined by JulianEra to avoid unnecessary duplication.

    The fields are defined as follows:

    • era - There are two eras, the current 'Anno Domini' (AD) and the previous era 'Before Christ' (BC).
    • year-of-era - The year-of-era for the current era increases uniformly from the epoch at year one. For the previous era the year increases from one as time goes backwards.
    • proleptic-year - The proleptic year is the same as the year-of-era for the current era. For the previous era, years have zero, then negative values.
    • month-of-year - There are 12 months in a year, numbered from 1 to 12.
    • day-of-month - There are between 28 and 31 days in each month, numbered from 1 to 31. Months 4, 6, 9 and 11 have 30 days, Months 1, 3, 5, 7, 8, 10 and 12 have 31 days. Month 2 has 28 days, or 29 in a leap year. The cutover month, September 1752, has a value range from 1 to 30, but a length of 19.
    • day-of-year - There are 365 days in a standard year and 366 in a leap year. The days are numbered from 1 to 365 or 1 to 366. The cutover year 1752 has values from 1 to 355 and a length of 355 days.

    Implementation Requirements

    This class is immutable and thread-safe.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.time.LocalDate CUTOVER
      The cutover date, Thursday 14th September 1752.
      static BritishCutoverChronology INSTANCE
      Singleton instance for the Coptic chronology.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BritishCutoverDate date​(int prolepticYear, int month, int dayOfMonth)
      Obtains a local date in British Cutover calendar system from the proleptic-year, month-of-year and day-of-month fields.
      BritishCutoverDate date​(java.time.chrono.Era era, int yearOfEra, int month, int dayOfMonth)
      Obtains a local date in British Cutover calendar system from the era, year-of-era, month-of-year and day-of-month fields.
      BritishCutoverDate date​(java.time.temporal.TemporalAccessor temporal)
      Obtains a British Cutover local date from another date-time object.
      BritishCutoverDate dateEpochDay​(long epochDay)
      Obtains a local date in the British Cutover calendar system from the epoch-day.
      BritishCutoverDate dateNow()
      Obtains the current British Cutover local date from the system clock in the default time-zone.
      BritishCutoverDate dateNow​(java.time.Clock clock)
      Obtains the current British Cutover local date from the specified clock.
      BritishCutoverDate dateNow​(java.time.ZoneId zone)
      Obtains the current British Cutover local date from the system clock in the specified time-zone.
      BritishCutoverDate dateYearDay​(int prolepticYear, int dayOfYear)
      Obtains a local date in British Cutover calendar system from the proleptic-year and day-of-year fields.
      BritishCutoverDate dateYearDay​(java.time.chrono.Era era, int yearOfEra, int dayOfYear)
      Obtains a local date in British Cutover calendar system from the era, year-of-era and day-of-year fields.
      JulianEra eraOf​(int eraValue)  
      java.util.List<java.time.chrono.Era> eras()  
      java.lang.String getCalendarType()
      Gets the calendar type of the underlying calendar system, which returns null.
      java.time.LocalDate getCutover()
      Gets the cutover date between the Julian and Gregorian calendar.
      java.lang.String getId()
      Gets the ID of the chronology - 'BritishCutover'.
      boolean isLeapYear​(long prolepticYear)
      Checks if the specified year is a leap year.
      java.time.chrono.ChronoLocalDateTime<BritishCutoverDate> localDateTime​(java.time.temporal.TemporalAccessor temporal)
      Obtains a British Cutover local date-time from another date-time object.
      int prolepticYear​(java.time.chrono.Era era, int yearOfEra)  
      java.time.temporal.ValueRange range​(java.time.temporal.ChronoField field)  
      BritishCutoverDate resolveDate​(java.util.Map<java.time.temporal.TemporalField,​java.lang.Long> fieldValues, java.time.format.ResolverStyle resolverStyle)  
      java.time.chrono.ChronoZonedDateTime<BritishCutoverDate> zonedDateTime​(java.time.Instant instant, java.time.ZoneId zone)
      Obtains a British Cutover zoned date-time in this chronology from an Instant.
      java.time.chrono.ChronoZonedDateTime<BritishCutoverDate> zonedDateTime​(java.time.temporal.TemporalAccessor temporal)
      Obtains a British Cutover zoned date-time from another date-time object.
      • Methods inherited from class java.time.chrono.AbstractChronology

        compareTo, equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.time.chrono.Chronology

        epochSecond, epochSecond, getDisplayName, period
    • Field Detail

      • CUTOVER

        public static final java.time.LocalDate CUTOVER
        The cutover date, Thursday 14th September 1752.
    • Constructor Detail

      • BritishCutoverChronology

        @Deprecated
        public BritishCutoverChronology()
        Deprecated.
        Use the singleton INSTANCE instead.
        Private constructor, that is public to satisfy the ServiceLoader.
    • Method Detail

      • getCutover

        public java.time.LocalDate getCutover()
        Gets the cutover date between the Julian and Gregorian calendar.

        The date returned is the first date that the Gregorian (ISO) calendar applies, which is Thursday 14th September 1752.

        Returns:
        the first date after the cutover, not null
      • getId

        public java.lang.String getId()
        Gets the ID of the chronology - 'BritishCutover'.

        The ID uniquely identifies the Chronology. It can be used to lookup the Chronology using Chronology.of(String).

        Specified by:
        getId in interface java.time.chrono.Chronology
        Returns:
        the chronology ID - 'BritishCutover'
        See Also:
        getCalendarType()
      • getCalendarType

        public java.lang.String 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:
        getCalendarType in interface java.time.chrono.Chronology
        Returns:
        the calendar system type, null
        See Also:
        getId()
      • date

        public BritishCutoverDate date​(java.time.chrono.Era era,
                                       int yearOfEra,
                                       int month,
                                       int dayOfMonth)
        Obtains a local date in British Cutover calendar system from the era, year-of-era, month-of-year and day-of-month fields.

        Dates in the middle of the cutover gap, such as the 10th September 1752, will not throw an exception. Instead, the date will be treated as a Julian date and converted to an ISO date, with the day of month shifted by 11 days.

        Specified by:
        date in interface java.time.chrono.Chronology
        Parameters:
        era - the British Cutover era, not null
        yearOfEra - the year-of-era
        month - the month-of-year
        dayOfMonth - the day-of-month
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
        java.lang.ClassCastException - if the era is not a JulianEra
      • date

        public BritishCutoverDate date​(int prolepticYear,
                                       int month,
                                       int dayOfMonth)
        Obtains a local date in British Cutover calendar system from the proleptic-year, month-of-year and day-of-month fields.

        Dates in the middle of the cutover gap, such as the 10th September 1752, will not throw an exception. Instead, the date will be treated as a Julian date and converted to an ISO date, with the day of month shifted by 11 days.

        Specified by:
        date in interface java.time.chrono.Chronology
        Parameters:
        prolepticYear - the proleptic-year
        month - the month-of-year
        dayOfMonth - the day-of-month
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • dateYearDay

        public BritishCutoverDate dateYearDay​(java.time.chrono.Era era,
                                              int yearOfEra,
                                              int dayOfYear)
        Obtains a local date in British Cutover calendar system from the era, year-of-era and day-of-year fields.

        The day-of-year takes into account the cutover, thus there are only 355 days in 1752.

        Specified by:
        dateYearDay in interface java.time.chrono.Chronology
        Parameters:
        era - the British Cutover era, not null
        yearOfEra - the year-of-era
        dayOfYear - the day-of-year
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
        java.lang.ClassCastException - if the era is not a JulianEra
      • dateYearDay

        public BritishCutoverDate dateYearDay​(int prolepticYear,
                                              int dayOfYear)
        Obtains a local date in British Cutover calendar system from the proleptic-year and day-of-year fields.

        The day-of-year takes into account the cutover, thus there are only 355 days in 1752.

        Specified by:
        dateYearDay in interface java.time.chrono.Chronology
        Parameters:
        prolepticYear - the proleptic-year
        dayOfYear - the day-of-year
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • dateEpochDay

        public BritishCutoverDate dateEpochDay​(long epochDay)
        Obtains a local date in the British Cutover calendar system from the epoch-day.
        Specified by:
        dateEpochDay in interface java.time.chrono.Chronology
        Parameters:
        epochDay - the epoch day
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • dateNow

        public BritishCutoverDate dateNow()
        Obtains the current British Cutover local date from the system clock in the default time-zone.

        This will query the system clock in 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:
        dateNow in interface java.time.chrono.Chronology
        Returns:
        the current British Cutover local date using the system clock and default time-zone, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • dateNow

        public BritishCutoverDate dateNow​(java.time.ZoneId zone)
        Obtains the current British Cutover local date from the system clock in the specified time-zone.

        This will query the system clock to 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:
        dateNow in interface java.time.chrono.Chronology
        Parameters:
        zone - the zone ID to use, not null
        Returns:
        the current British Cutover local date using the system clock, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • dateNow

        public BritishCutoverDate dateNow​(java.time.Clock clock)
        Obtains the current British Cutover 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:
        dateNow in interface java.time.chrono.Chronology
        Parameters:
        clock - the clock to use, not null
        Returns:
        the current British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • date

        public BritishCutoverDate date​(java.time.temporal.TemporalAccessor temporal)
        Obtains a British Cutover local date from another date-time object.
        Specified by:
        date in interface java.time.chrono.Chronology
        Parameters:
        temporal - the date-time object to convert, not null
        Returns:
        the British Cutover local date, not null
        Throws:
        java.time.DateTimeException - if unable to create the date
      • localDateTime

        public java.time.chrono.ChronoLocalDateTime<BritishCutoverDate> localDateTime​(java.time.temporal.TemporalAccessor temporal)
        Obtains a British Cutover local date-time from another date-time object.
        Specified by:
        localDateTime in interface java.time.chrono.Chronology
        Parameters:
        temporal - the date-time object to convert, not null
        Returns:
        the British Cutover local date-time, not null
        Throws:
        java.time.DateTimeException - if unable to create the date-time
      • zonedDateTime

        public java.time.chrono.ChronoZonedDateTime<BritishCutoverDate> zonedDateTime​(java.time.temporal.TemporalAccessor temporal)
        Obtains a British Cutover zoned date-time from another date-time object.
        Specified by:
        zonedDateTime in interface java.time.chrono.Chronology
        Parameters:
        temporal - the date-time object to convert, not null
        Returns:
        the British Cutover zoned date-time, not null
        Throws:
        java.time.DateTimeException - if unable to create the date-time
      • zonedDateTime

        public java.time.chrono.ChronoZonedDateTime<BritishCutoverDate> zonedDateTime​(java.time.Instant instant,
                                                                                      java.time.ZoneId zone)
        Obtains a British Cutover zoned date-time in this chronology from an Instant.
        Specified by:
        zonedDateTime in interface java.time.chrono.Chronology
        Parameters:
        instant - the instant to create the date-time from, not null
        zone - the time-zone, not null
        Returns:
        the British Cutover zoned date-time, not null
        Throws:
        java.time.DateTimeException - if the result exceeds the supported range
      • isLeapYear

        public boolean isLeapYear​(long prolepticYear)
        Checks if the specified year is a leap year.

        The result will return the same as JulianChronology.isLeapYear(long) for year 1752 and earlier, and IsoChronology.isLeapYear(long) otherwise. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.

        Specified by:
        isLeapYear in interface java.time.chrono.Chronology
        Parameters:
        prolepticYear - the proleptic-year to check, not validated for range
        Returns:
        true if the year is a leap year
      • prolepticYear

        public int prolepticYear​(java.time.chrono.Era era,
                                 int yearOfEra)
        Specified by:
        prolepticYear in interface java.time.chrono.Chronology
      • eraOf

        public JulianEra eraOf​(int eraValue)
        Specified by:
        eraOf in interface java.time.chrono.Chronology
      • eras

        public java.util.List<java.time.chrono.Era> eras()
        Specified by:
        eras in interface java.time.chrono.Chronology
      • range

        public java.time.temporal.ValueRange range​(java.time.temporal.ChronoField field)
        Specified by:
        range in interface java.time.chrono.Chronology
      • resolveDate

        public BritishCutoverDate resolveDate​(java.util.Map<java.time.temporal.TemporalField,​java.lang.Long> fieldValues,
                                              java.time.format.ResolverStyle resolverStyle)
        Specified by:
        resolveDate in interface java.time.chrono.Chronology
        Overrides:
        resolveDate in class java.time.chrono.AbstractChronology