public
class
JapaneseCalendar
extends GregorianCalendar
java.lang.Object | |||
↳ | android.icu.util.Calendar | ||
↳ | android.icu.util.GregorianCalendar | ||
↳ | android.icu.util.JapaneseCalendar |
JapaneseCalendar
is a subclass of GregorianCalendar
that numbers years and eras based on the reigns of the Japanese emperors.
The Japanese calendar is identical to the Gregorian calendar in all respects
except for the year and era. The ascension of each emperor to the throne
begins a new era, and the years of that era are numbered starting with the
year of ascension as year 1.
Note that in the year of an imperial ascension, there are two possible sets of year and era values: that for the old era and for the new. For example, a new era began on January 7, 1989 AD. Strictly speaking, the first six days of that year were in the Showa era, e.g. "January 6, 64 Showa", while the rest of the year was in the Heisei era, e.g. "January 7, 1 Heisei". This class handles this distinction correctly when computing dates. However, in lenient mode either form of date is acceptable as input.
In modern times, eras have started on January 8, 1868 AD, Gregorian (Meiji),
July 30, 1912 (Taisho), December 25, 1926 (Showa), and January 7, 1989 (Heisei). Constants
for these eras, suitable for use in the ERA
field, are provided
in this class. Note that the number used for each era is more or
less arbitrary. Currently, the era starting in 1053 AD is era #0; however this
may change in the future as we add more historical data. Use the predefined
constants rather than using actual, absolute numbers.
This class should not be subclassed.
JapaneseCalendar usually should be instantiated using
getInstance(ULocale)
passing in a ULocale
with the tag "@calendar=japanese"
.
See also:
Inherited constants |
---|
From
class
android.icu.util.GregorianCalendar
|
From
class
android.icu.util.Calendar
|
Fields | |
---|---|
public
static
final
int |
CURRENT_ERA
|
public
static
final
int |
HEISEI
Constant for the era starting on Jan. |
public
static
final
int |
MEIJI
Constant for the era starting on Sept. |
public
static
final
int |
SHOWA
Constant for the era starting on Dec. |
public
static
final
int |
TAISHO
Constant for the era starting on July 30, 1912 AD. |
Inherited fields |
---|
From
class
android.icu.util.GregorianCalendar
|
From
class
android.icu.util.Calendar
|
Public constructors | |
---|---|
JapaneseCalendar()
Constructs a default |
|
JapaneseCalendar(TimeZone zone)
Constructs a |
|
JapaneseCalendar(Locale aLocale)
Constructs a |
|
JapaneseCalendar(ULocale locale)
Constructs a |
|
JapaneseCalendar(TimeZone zone, Locale aLocale)
Constructs a |
|
JapaneseCalendar(TimeZone zone, ULocale locale)
Constructs a |
|
JapaneseCalendar(Date date)
Constructs a |
|
JapaneseCalendar(int era, int year, int month, int date)
Constructs a |
|
JapaneseCalendar(int year, int month, int date)
Constructs a |
|
JapaneseCalendar(int year, int month, int date, int hour, int minute, int second)
Constructs a |
Public methods | |
---|---|
int
|
getActualMaximum(int field)
Return the maximum value that this field could have, given the current date. |
String
|
getType()
[icu] Returns the calendar type name string for this Calendar object. |
Protected methods | |
---|---|
void
|
handleComputeFields(int julianDay)
Override Calendar to compute several fields specific to the hybrid Gregorian-Julian calendar system. |
int
|
handleGetExtendedYear()
Returns the extended year defined by the current fields. |
int
|
handleGetLimit(int field, int limitType)
Override GregorianCalendar. |
Inherited methods | |
---|---|
From
class
android.icu.util.GregorianCalendar
| |
From
class
android.icu.util.Calendar
| |
From
class
java.lang.Object
| |
From
interface
java.lang.Comparable
|
JapaneseCalendar ()
Constructs a default JapaneseCalendar
using the current time
in the default time zone with the default locale.
JapaneseCalendar (TimeZone zone)
Constructs a JapaneseCalendar
based on the current time
in the given time zone with the default locale.
Parameters | |
---|---|
zone |
TimeZone :
the given time zone.
|
JapaneseCalendar (Locale aLocale)
Constructs a JapaneseCalendar
based on the current time
in the default time zone with the given locale.
Parameters | |
---|---|
aLocale |
Locale :
the given locale.
|
JapaneseCalendar (ULocale locale)
Constructs a JapaneseCalendar
based on the current time
in the default time zone with the given locale.
Parameters | |
---|---|
locale |
ULocale :
the given ulocale.
|
JapaneseCalendar (TimeZone zone, Locale aLocale)
Constructs a JapaneseCalendar
based on the current time
in the given time zone with the given locale.
Parameters | |
---|---|
zone |
TimeZone :
the given time zone. |
aLocale |
Locale :
the given locale.
|
JapaneseCalendar (TimeZone zone, ULocale locale)
Constructs a JapaneseCalendar
based on the current time
in the given time zone with the given locale.
Parameters | |
---|---|
zone |
TimeZone :
the given time zone. |
locale |
ULocale :
the given ulocale.
|
JapaneseCalendar (Date date)
Constructs a JapaneseCalendar
with the given date set
in the default time zone with the default locale.
Parameters | |
---|---|
date |
Date :
The date to which the new calendar is set.
|
JapaneseCalendar (int era, int year, int month, int date)
Constructs a JapaneseCalendar
with the given date set
in the default time zone with the default locale.
Parameters | |
---|---|
era |
int :
The imperial era used to set the calendar's ERA field.
Eras are numbered starting with the Tenki era, which
began in 1053 AD Gregorian, as era zero. Recent
eras can be specified using the constants
MEIJI (which started in 1868 AD),
TAISHO (1912 AD),
SHOWA (1926 AD), and
HEISEI (1989 AD). |
year |
int :
The value used to set the calendar's YEAR field,
in terms of the era. |
month |
int :
The value used to set the calendar's MONTH field.
The value is 0-based. e.g., 0 for January. |
date |
int :
The value used to set the calendar's DATE field.
|
JapaneseCalendar (int year, int month, int date)
Constructs a JapaneseCalendar
with the given date set
in the default time zone with the default locale.
Parameters | |
---|---|
year |
int :
The value used to set the calendar's YEAR field,
in the era Heisei, the most current at the time this
class was last updated. |
month |
int :
The value used to set the calendar's MONTH field.
The value is 0-based. e.g., 0 for January. |
date |
int :
The value used to set the calendar's DATE field.
|
JapaneseCalendar (int year, int month, int date, int hour, int minute, int second)
Constructs a JapaneseCalendar
with the given date
and time set for the default time zone with the default locale.
Parameters | |
---|---|
year |
int :
The value used to set the calendar's YEAR time field,
in the era Heisei, the most current at the time of this
writing. |
month |
int :
The value used to set the calendar's MONTH time field.
The value is 0-based. e.g., 0 for January. |
date |
int :
The value used to set the calendar's DATE time field. |
hour |
int :
The value used to set the calendar's HOUR_OF_DAY time field. |
minute |
int :
The value used to set the calendar's MINUTE time field. |
second |
int :
The value used to set the calendar's SECOND time field.
|
int getActualMaximum (int field)
Return the maximum value that this field could have, given the current date. For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, for some years the actual maximum for MONTH is 12, and for others 13.
Parameters | |
---|---|
field |
int :
the field whose maximum is desired |
Returns | |
---|---|
int |
the maximum of the given field for the current date of this calendar |
String getType ()
[icu] 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
Returns | |
---|---|
String |
legacy calendar type name string |
void handleComputeFields (int julianDay)
Override Calendar to compute several fields specific to the hybrid Gregorian-Julian calendar system. These are:
Parameters | |
---|---|
julianDay |
int
|
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.
Returns | |
---|---|
int |
the extended year |
int handleGetLimit (int field, int limitType)
Override GregorianCalendar. We should really handle YEAR_WOY and EXTENDED_YEAR here too to implement the 1..5000000 range, but it's not critical.
Parameters | |
---|---|
field |
int :
one of the above field numbers |
limitType |
int :
one of MINIMUM , GREATEST_MINIMUM ,
LEAST_MAXIMUM , or MAXIMUM
|
Returns | |
---|---|
int |