sun.util.calendar
public final class: Era [javadoc |
source]
java.lang.Object
sun.util.calendar.Era
The class
Era
represents a calendar era that defines a
period of time in which the same year numbering is used. For
example, Gregorian year 2004 is
Heisei 16 in the Japanese
calendar system. An era starts at any point of time (Gregorian) that is
represented by
CalendarDate
.
Era
s that are applicable to a particular calendar
system can be obtained by calling CalendarSystem#getEras
one of which can be used to specify a date in
CalendarDate
.
The following era names are defined in this release.
Calendar system Era name Since (in Gregorian)
-----------------------------------------------------------------------
Japanese calendar Meiji 1868-01-01 midnight local time
Taisho 1912-07-30 midnight local time
Showa 1926-12-26 midnight local time
Heisei 1989-01-08 midnight local time
Julian calendar BeforeCommonEra -292275055-05-16T16:47:04.192Z
CommonEra 0000-12-30 midnight local time
Taiwanese calendar MinGuo 1911-01-01 midnight local time
Thai Buddhist calendar BuddhistEra -543-01-01 midnight local time
-----------------------------------------------------------------------
- author:
Masayoshi
- Okutsu
- since:
1.5
-
Constructor: |
public Era(String name,
String abbr,
long since,
boolean localTime) {
this.name = name;
this.abbr = abbr;
this.since = since;
this.localTime = localTime;
Gregorian gcal = CalendarSystem.getGregorianCalendar();
BaseCalendar.Date d = (BaseCalendar.Date) gcal.newCalendarDate(null);
gcal.getCalendarDate(since, d);
sinceDate = new ImmutableGregorianDate(d);
}
Constructs an Era instance. Parameters:
name - the era name (e.g., "BeforeCommonEra" for the Julian calendar system)
abbr - the abbreviation of the era name (e.g., "B.C.E." for "BeforeCommonEra")
since - the time (millisecond offset from January 1, 1970
(Gregorian) UTC or local time) when the era starts, inclusive.
localTime - true if since
specifies a local time; false if
since specifies UTC
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from sun.util.calendar.Era Detail: |
public boolean equals(Object o) {
if (!(o instanceof Era)) {
return false;
}
Era that = (Era) o;
return name.equals(that.name)
&& abbr.equals(that.abbr)
&& since == that.since
&& localTime == that.localTime;
}
|
public String getAbbreviation() {
return abbr;
}
|
public String getDiaplayAbbreviation(Locale locale) {
return abbr;
}
|
public String getDisplayName(Locale locale) {
return name;
}
|
public String getName() {
return name;
}
|
public long getSince(TimeZone zone) {
if (zone == null || !localTime) {
return since;
}
int offset = zone.getOffset(since);
return since - offset;
}
|
public CalendarDate getSinceDate() {
return sinceDate;
}
|
public int hashCode() {
if (hash == 0) {
hash = name.hashCode() ^ abbr.hashCode() ^ (int)since ^ (int)(since > > 32)
^ (localTime ? 1 : 0);
}
return hash;
}
|
public boolean isLocalTime() {
return localTime;
}
|
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('[');
sb.append(getName()).append(" (");
sb.append(getAbbreviation()).append(')');
sb.append(" since ").append(getSinceDate());
if (localTime) {
sb.setLength(sb.length() - 1); // remove 'Z'
sb.append(" local time");
}
sb.append(']');
return sb.toString();
}
|