public class XmlCalendar extends GregorianCalendar
GregorianCalendar
.
XmlCalendar modifies several key details in the behavior of
GregorianCalendar to make it more useful when dealing with XML dates.
It is easy to convert between XmlCalendar and GDate
, or to
parse or emit an XmlCalendar using a standard XML Schema
lexical representation.
GregorianCalendar
, which chooses 1970. The reason 0 is preferable
is that it is a leap year and so it permits the date --2-29 to be specified
stably. A different default year can be chosen via the static method
XmlCalendar.setDefaultYear()
, or by setting the
system property "user.defaultyear". If you do change this value, you should
pick another leap year such as 2000 and avoid non-leap years such as 1900.
TimeZone.getDefault()
if not.
For example, the XML timezone "Z" is translated to "GMT"; the XML timezone "+05:00" is translated to "GMT+05:00".
Calendar.Builder
AD, BC
ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
Constructor and Description |
---|
XmlCalendar()
Constructs an empty instance with no fields set.
|
XmlCalendar(Date date)
Constructs an XmlCalendar from a Date.
|
XmlCalendar(GDateSpecification date)
Constructs an XmlCalendar from a GDate.
|
XmlCalendar(int year,
int month,
int day,
int hour,
int minute,
int second,
BigDecimal fraction)
Constructs an XmlCalendar with the specified year, month, day,
hours, minutes, seconds, and optional fractional seconds, in
the default timezone.
|
XmlCalendar(int year,
int month,
int day,
int hour,
int minute,
int second,
BigDecimal fraction,
int tzSign,
int tzHour,
int tzMinute)
Constructs an XmlCalendar with the specified year, month, day,
hours, minutes, seconds, and optional fractional seconds, in
the specified timezone.
|
XmlCalendar(String xmlSchemaDateString)
Constructs an XmlCalendar for a standard XML
schema formatted date string.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeTime()
Overrides GregorianCalendar.computeTime to apply a different
default year.
|
int |
get(int field)
Gets the value for a given time field.
|
static int |
getDefaultYear()
Returns the default year that is used when no year is specified.
|
static void |
setDefaultYear(int year)
Sets the default year to be used when no year is specified.
|
String |
toString()
Prints the XmlCalendar using a standard XML Schema
format, as described in XmlCalendar(String s).
|
add, clone, computeFields, equals, from, getActualMaximum, getActualMinimum, getCalendarType, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, getWeeksInWeekYear, getWeekYear, hashCode, isLeapYear, isWeekDateSupported, roll, roll, setGregorianChange, setTimeZone, setWeekDate, toZonedDateTime
after, before, clear, clear, compareTo, complete, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toInstant
public XmlCalendar(String xmlSchemaDateString)
public XmlCalendar(GDateSpecification date)
public XmlCalendar(Date date)
public XmlCalendar(int year, int month, int day, int hour, int minute, int second, BigDecimal fraction)
public XmlCalendar(int year, int month, int day, int hour, int minute, int second, BigDecimal fraction, int tzSign, int tzHour, int tzMinute)
public XmlCalendar()
public int get(int field)
public static int getDefaultYear()
public static void setDefaultYear(int year)
protected void computeTime()
computeTime
in class GregorianCalendar