Interface GDateSpecification
-
- All Known Implementing Classes:
GDate
,GDateBuilder
public interface GDateSpecification
Represents an XML Schema-compatible Gregorian date.Both the immutable GDate and the mutable GDateBuilder are GDateSpecifications. Use this interface where you want to allow callers to pass any implementation of a GDate.
- See Also:
GDate
,XmlCalendar
-
-
Field Summary
Fields Modifier and Type Field Description static int
HAS_DAY
Day of month is specified.static int
HAS_MONTH
Month of year is specified.static int
HAS_TIME
Time of day is specified.static int
HAS_TIMEZONE
Timezone is specified.static int
HAS_YEAR
Year is specified.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
canonicalString()
The canonical string representation.int
compareToGDate(GDateSpecification gdatespec)
Comparison to another GDate.int
getBuiltinTypeCode()
Returns the builtin type code for the shape of the information contained in this instance, or 0 if the instance doesn't contain information corresponding to a Schema type.XmlCalendar
getCalendar()
Retrieves the value of the current time as anXmlCalendar
.java.util.Date
getDate()
Retrieves the value of the current time as a java.util.Date instance.int
getDay()
Gets the day-of-month.int
getFlags()
Returns a combination of flags indicating the information contained by this GDate.java.math.BigDecimal
getFraction()
Gets the fraction-of-second.int
getHour()
Gets the hour-of-day.int
getJulianDate()
Returns the Julian date corresponding to this Gregorian date.int
getMillisecond()
Gets the rounded millisecond value.int
getMinute()
Gets the minute-of-hour.int
getMonth()
Gets the month-of-year.int
getSecond()
Gets the second-of-minute.int
getTimeZoneHour()
Gets the time zone hour.int
getTimeZoneMinute()
Gets the time zone minutes.int
getTimeZoneSign()
Gets the time zone sign.int
getYear()
Gets the year.boolean
hasDate()
True if this date/time specification specifies a full date (year, month, day)boolean
hasDay()
True if this date/time specification specifies a day-of-month.boolean
hasMonth()
True if this date/time specification specifies a month-of-year.boolean
hasTime()
True if this date/time specification specifies a time-of-day.boolean
hasTimeZone()
True if this date/time specification specifies a timezone.boolean
hasYear()
True if this date/time specification specifies a year.boolean
isImmutable()
True if this GDate specification is immutable.boolean
isValid()
True if this GDate corresponds to a valid gregorian date value in XML schema.java.lang.String
toString()
The natural string representation.
-
-
-
Field Detail
-
HAS_TIMEZONE
static final int HAS_TIMEZONE
Timezone is specified. SeegetFlags()
.- See Also:
- Constant Field Values
-
HAS_YEAR
static final int HAS_YEAR
Year is specified. SeegetFlags()
.- See Also:
- Constant Field Values
-
HAS_MONTH
static final int HAS_MONTH
Month of year is specified. SeegetFlags()
.- See Also:
- Constant Field Values
-
HAS_DAY
static final int HAS_DAY
Day of month is specified. SeegetFlags()
.- See Also:
- Constant Field Values
-
HAS_TIME
static final int HAS_TIME
Time of day is specified. SeegetFlags()
.- See Also:
- Constant Field Values
-
-
Method Detail
-
getFlags
int getFlags()
Returns a combination of flags indicating the information contained by this GDate. The five flags areHAS_TIMEZONE
,HAS_YEAR
,HAS_MONTH
,HAS_DAY
, andHAS_TIME
.
-
isImmutable
boolean isImmutable()
True if this GDate specification is immutable. GDate returns true, and GDateBuilder returns false.
-
isValid
boolean isValid()
True if this GDate corresponds to a valid gregorian date value in XML schema.
-
hasTimeZone
boolean hasTimeZone()
True if this date/time specification specifies a timezone.
-
hasYear
boolean hasYear()
True if this date/time specification specifies a year.
-
hasMonth
boolean hasMonth()
True if this date/time specification specifies a month-of-year.
-
hasDay
boolean hasDay()
True if this date/time specification specifies a day-of-month.
-
hasTime
boolean hasTime()
True if this date/time specification specifies a time-of-day.
-
hasDate
boolean hasDate()
True if this date/time specification specifies a full date (year, month, day)
-
getYear
int getYear()
Gets the year. Should be a four-digit year specification.
-
getMonth
int getMonth()
Gets the month-of-year. January is 1.
-
getDay
int getDay()
Gets the day-of-month. The first day of each month is 1.
-
getHour
int getHour()
Gets the hour-of-day. Midnight is 0, and 11PM is 23.
-
getMinute
int getMinute()
Gets the minute-of-hour. Range from 0 to 59.
-
getSecond
int getSecond()
Gets the second-of-minute. Range from 0 to 59.
-
getTimeZoneSign
int getTimeZoneSign()
Gets the time zone sign. For time zones east of GMT, this is positive; for time zones west, this is negative.
-
getTimeZoneHour
int getTimeZoneHour()
Gets the time zone hour. This is always positive: for the sign, look at getTimeZoneSign().
-
getTimeZoneMinute
int getTimeZoneMinute()
Gets the time zone minutes. This is always positive: for the sign, look at getTimeZoneSign().
-
getFraction
java.math.BigDecimal getFraction()
Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
-
getMillisecond
int getMillisecond()
Gets the rounded millisecond value. Range from 0 to 999
-
getJulianDate
int getJulianDate()
Returns the Julian date corresponding to this Gregorian date. The Julian date (JD) is a continuous count of days from 1 January 4713 BC.
-
getCalendar
XmlCalendar getCalendar()
Retrieves the value of the current time as anXmlCalendar
.XmlCalendar
is a subclass ofGregorianCalendar
which is slightly customized to match XML schema date rules.The returned
XmlCalendar
has only those time and date fields set that are reflected in the GDate object. Because of the way theCalendar
contract works, any information in the isSet() vanishes as soon as you view any unset field using get() methods. This means that if it is important to understand which date fields are set, you must call isSet() first before get().
-
getDate
java.util.Date getDate()
Retrieves the value of the current time as a java.util.Date instance.
-
compareToGDate
int compareToGDate(GDateSpecification gdatespec)
Comparison to another GDate.- Returns -1 if this < date. (less-than)
- Returns 0 if this == date. (equal)
- Returns 1 if this > date. (greater-than)
- Returns 2 if this <> date. (incomparable)
- Parameters:
gdatespec
- the date to compare against.
-
getBuiltinTypeCode
int getBuiltinTypeCode()
Returns the builtin type code for the shape of the information contained in this instance, or 0 if the instance doesn't contain information corresponding to a Schema type.Value will be equal to
SchemaType.BTC_NOT_BUILTIN
,SchemaType.BTC_G_YEAR
,SchemaType.BTC_G_YEAR_MONTH
,SchemaType.BTC_G_MONTH
,SchemaType.BTC_G_MONTH_DAY
,SchemaType.BTC_G_DAY
,SchemaType.BTC_DATE
,SchemaType.BTC_DATE_TIME
, orSchemaType.BTC_TIME
.
-
canonicalString
java.lang.String canonicalString()
The canonical string representation. Specific moments or times-of-day in a specified timezone are normalized to UTC time to produce a canonical string form for them. Other recurring time specifications keep their timezone information.
-
toString
java.lang.String toString()
The natural string representation. This represents the information that is available, including timezone. For types that correspond to defined schema types (schemaBuiltinTypeCode() > 0), this provides the natural lexical representation. When both time and timezone are specified, this string is not the canonical representation unless the timezone is UTC (Z) (since the same moment in time can be expressed in different timezones). To get a canonical string, use the canonicalString() method.- Overrides:
toString
in classjava.lang.Object
-
-