Class TaiwanCalendar

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Calendar>

    public class TaiwanCalendar
    extends GregorianCalendar
    TaiwanCalendar is a subclass of GregorianCalendar that numbers years since 1912.

    The Taiwan calendar is identical to the Gregorian calendar in all respects except for the year and era. Years are numbered since 1912 AD (Gregorian).

    The Taiwan Calendar has one era: MINGUO.

    This class should not be subclassed.

    TaiwanCalendar usually should be instantiated using Calendar.getInstance(ULocale) passing in a ULocale with the tag "@calendar=roc".

    Author:
    Laura Werner, Alan Liu, Steven R. Loomis
    See Also:
    Calendar, GregorianCalendar, Serialized Form
    • Field Detail

      • BEFORE_MINGUO

        public static final int BEFORE_MINGUO
        Constant for the Taiwan Era for years before Minguo 1. Before Minuo 1 is Gregorian 1911, Before Minguo 2 is Gregorian 1910 and so on.
        See Also:
        Calendar.ERA, Constant Field Values
      • MINGUO

        public static final int MINGUO
        Constant for the Taiwan Era for Minguo. Minguo 1 is 1912 in Gregorian calendar.
        See Also:
        Calendar.ERA, Constant Field Values
    • Constructor Detail

      • TaiwanCalendar

        public TaiwanCalendar()
        Constructs a TaiwanCalendar using the current time in the default time zone with the default locale.
      • TaiwanCalendar

        public TaiwanCalendar​(TimeZone zone)
        Constructs a TaiwanCalendar based on the current time in the given time zone with the default locale.
        Parameters:
        zone - the given time zone.
      • TaiwanCalendar

        public TaiwanCalendar​(java.util.Locale aLocale)
        Constructs a TaiwanCalendar based on the current time in the default time zone with the given locale.
        Parameters:
        aLocale - the given locale.
      • TaiwanCalendar

        public TaiwanCalendar​(ULocale locale)
        Constructs a TaiwanCalendar based on the current time in the default time zone with the given locale.
        Parameters:
        locale - the given ulocale.
      • TaiwanCalendar

        public TaiwanCalendar​(TimeZone zone,
                              java.util.Locale aLocale)
        Constructs a TaiwanCalendar based on the current time in the given time zone with the given locale.
        Parameters:
        zone - the given time zone.
      • TaiwanCalendar

        public TaiwanCalendar​(TimeZone zone,
                              ULocale locale)
        Constructs a TaiwanCalendar based on the current time in the given time zone with the given locale.
        Parameters:
        zone - the given time zone.
        locale - the given ulocale.
      • TaiwanCalendar

        public TaiwanCalendar​(java.util.Date date)
        Constructs a TaiwanCalendar with the given date set in the default time zone with the default locale.
        Parameters:
        date - The date to which the new calendar is set.
      • TaiwanCalendar

        public TaiwanCalendar​(int year,
                              int month,
                              int date)
        Constructs a TaiwanCalendar with the given date set in the default time zone with the default locale.
        Parameters:
        year - The value used to set the calendar's YEAR time field.
        month - The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.
        date - The value used to set the calendar's DATE time field.
      • TaiwanCalendar

        public TaiwanCalendar​(int year,
                              int month,
                              int date,
                              int hour,
                              int minute,
                              int second)
        Constructs a TaiwanCalendar with the given date and time set for the default time zone with the default locale.
        Parameters:
        year - The value used to set the calendar's YEAR time field.
        month - The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.
        date - The value used to set the calendar's DATE time field.
        hour - The value used to set the calendar's HOUR_OF_DAY time field.
        minute - The value used to set the calendar's MINUTE time field.
        second - The value used to set the calendar's SECOND time field.
    • Method Detail

      • handleGetExtendedYear

        protected int handleGetExtendedYear()
        Returns the extended year defined by the current fields. This will use the EXTENDED_YEAR field or the YEAR and supra-year fields (such as ERA) specific to the calendar system, depending on which set of fields is newer.
        Overrides:
        handleGetExtendedYear in class GregorianCalendar
        Returns:
        the extended year
      • handleComputeFields

        protected void handleComputeFields​(int julianDay)
        Override Calendar to compute several fields specific to the hybrid Gregorian-Julian calendar system. These are:
        • ERA
        • YEAR
        • MONTH
        • DAY_OF_MONTH
        • DAY_OF_YEAR
        • EXTENDED_YEAR
        Overrides:
        handleComputeFields in class GregorianCalendar
      • handleGetLimit

        protected int handleGetLimit​(int field,
                                     int limitType)
        Override GregorianCalendar. There is only one Taiwan ERA. We should really handle YEAR, YEAR_WOY, and EXTENDED_YEAR here too to implement the 1..5000000 range, but it's not critical.
        Overrides:
        handleGetLimit in class GregorianCalendar
        Parameters:
        field - one of the above field numbers
        limitType - one of MINIMUM, GREATEST_MINIMUM, LEAST_MAXIMUM, or MAXIMUM
      • getType

        public java.lang.String getType()
        Returns the calendar type name string for this Calendar object. The returned string is the legacy ICU calendar attribute value, for example, "gregorian" or "japanese".

        See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions

        Overrides:
        getType in class GregorianCalendar
        Returns:
        legacy calendar type name string