Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]
org.apache.xmlbeans
public final class: GDateBuilder [javadoc | source]
java.lang.Object
   org.apache.xmlbeans.GDateBuilder

All Implemented Interfaces:
    java$io$Serializable, GDateSpecification

Used to build GDates .

Like GDate, a GDateBuilder represents an Gregorian Date, Time, and Timezone, or subset of information (Year, Month, Day, Time, Timezone, or some combination). Wherever it provides guidance, the XML Schema 1.0 specification (plus published errata) is followed.

Instances may separately set or clear the year, month, day-of-month, and time-of-day. Not all operations are meaningful on all combinations. In particular, timezone normalization is only possible if there is a time, or a time together with a full date.
Field Summary
static final  BigInteger TEN     
Constructor:
 public GDateBuilder() 
 public GDateBuilder(GDateSpecification gdate) 
    Construts a GDateBuilder by copying another GDateSpecificaiton.
 public GDateBuilder(CharSequence string) 
    Constructs a GDateBuilder from a lexical representation. The lexical space contains the union of the lexical spaces of all the schema date/time types (except for duration).
 public GDateBuilder(Calendar calendar) 
 public GDateBuilder(Date date) 
    Constructs a GDateBuilder based on a java.util.Date.

    The current offset of the default timezone is used as the timezone.

    For example, if eastern daylight time is in effect at the given date, the timezone on the east coast of the united states translates to GMT-05:00 (EST) + 1:00 (DT offset) == GMT-04:00.

    Parameters:
    date - the date object to copy
 public GDateBuilder(int year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fraction) 
    Constructs a GDateBuilder with the specified year, month, day, hours, minutes, seconds, and optional fractional seconds, in an unspecified timezone.

    Note that by not specifying the timezone the GDateBuilder becomes partially unordered with respect to timesthat do have a specified timezone.

    Parameters:
    year - The year
    month - The month, from 1-12
    day - The day of month, from 1-31
    hour - The hour of day, from 0-23
    minute - The minute of hour, from 0-59
    second - The second of minute, from 0-59
    fraction - The fraction of second, 0.0 to 0.999... (may be null)
 public GDateBuilder(int year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fraction,
    int tzSign,
    int tzHour,
    int tzMinute) 
    Constructs an absolute GDateBuilder with the specified year, month, day, hours, minutes, seconds, and optional fractional seconds, and in the timezone specified.

    Note that you can reexpress the GDateBuilder in any timezone using normalizeToTimeZone(). The normalize() method normalizes to UTC.

    If you wish to have a time or date that isn't in a specified timezone, then use the constructor that does not include the timezone arguments.

    Parameters:
    year - the year
    month - the month, from 1-12
    day - the day of month, from 1-31
    hour - the hour of day, from 0-23
    minute - the minute of hour, from 0-59
    second - the second of minute, from 0-59
    fraction - the fraction of second, 0.0 to 0.999... (may be null)
    tzSign - the timezone offset sign, either +1, 0, or -1
    tzHour - the timezone offset hour
    tzMinute - the timezone offset minute
Method from org.apache.xmlbeans.GDateBuilder Summary:
addDuration,   addGDuration,   btcForFlags,   canonicalString,   clearDay,   clearMonth,   clearTime,   clearTimeZone,   clearYear,   clone,   compareGDate,   compareToGDate,   dateForGDate,   getBuiltinTypeCode,   getCalendar,   getDate,   getDay,   getFlags,   getFraction,   getHour,   getJulianDate,   getMillisecond,   getMinute,   getMonth,   getSecond,   getTimeZoneHour,   getTimeZoneMinute,   getTimeZoneSign,   getYear,   hasDate,   hasDay,   hasMonth,   hasTime,   hasTimeZone,   hasYear,   isImmutable,   isValid,   isValidGDate,   julianDateForGDate,   normalize,   normalize24h,   normalizeToTimeZone,   normalizeToTimeZone,   setBuiltinTypeCode,   setDate,   setDay,   setGDate,   setJulianDate,   setMonth,   setTime,   setTimeZone,   setTimeZone,   setYear,   subtractGDuration,   toGDate,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xmlbeans.GDateBuilder Detail:
 public  void addDuration(int sign,
    int year,
    int month,
    int day,
    int hour,
    int minute,
    int second,
    BigDecimal fraction) 
    Adds a given duration to the date/time.
 public  void addGDuration(GDurationSpecification duration) 
    Adds a given duration to the date/time.
 static int btcForFlags(int flags) 
 public 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.
 public  void clearDay() 
    Clears the day-of-month. After clearing. hasDay returns false and the value of getDay is undefined.
 public  void clearMonth() 
    Clears the month-of-year. After clearing. hasMonth returns false and the value of getMonth is undefined.
 public  void clearTime() 
    Clears the time-of-day. After clearing. hasTime returns false and the value of getTime is undefined.
 public  void clearTimeZone() 
    Clears the timezone. After clearing. hasTimeZone returns false and the value of getTimeZoneHour and getTimeZoneMinute are undefined. Does not change the other time fields.
 public  void clearYear() 
    Clears the year. After clearing, hasYear returns false and the value of getYear is undefined.
 public Object clone() 
    Builds another GDateBuilder with the same value as this one.
 static final int compareGDate(GDateSpecification tdate,
    GDateSpecification datespec) 
 public final int compareToGDate(GDateSpecification datespec) 
    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)
    Two instances are incomparable if they have different amounts of information.
 static Date dateForGDate(GDateSpecification date) 
 public final int getBuiltinTypeCode() 
 public XmlCalendar getCalendar() 
    Retrieves the value of the current time as an XmlCalendar .

    XmlCalendar is a subclass of java.util.GregorianCalendar 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 the java.util.Calendar 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().

 public Date getDate() 
    Retrieves the value of the current time as a java.util.Date instance.
 public final int getDay() 
    Gets the day-of-month. The first day of each month is 1.
 public int getFlags() 
    Returns a combination of flags indicating the information contained by this GDate. The five flags are HAS_TIMEZONE, HAS_YEAR, HAS_MONTH, HAS_DAY, and HAS_TIME.
 public final BigDecimal getFraction() 
    Gets the fraction-of-second. Range from 0 (inclusive) to 1 (exclusive).
 public final int getHour() 
    Gets the hour-of-day. Midnight is 0, and 11PM is 23.
 public final 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.
 public final int getMillisecond() 
    Gets the rounded millisecond value. Range from 0 to 999
 public final int getMinute() 
    Gets the minute-of-hour. Range from 0 to 59.
 public final int getMonth() 
    Gets the month-of-year. January is 1.
 public final int getSecond() 
    Gets the second-of-minute. Range from 0 to 59.
 public final int getTimeZoneHour() 
    Gets the time zone hour. This is always positive: for the sign, look at getTimeZoneSign().
 public final int getTimeZoneMinute() 
    Gets the time zone minutes. This is always positive: for the sign, look at getTimeZoneSign().
 public final int getTimeZoneSign() 
    Gets the time zone sign. For time zones east of GMT, this is positive; for time zones west, this is negative.
 public final int getYear() 
    Gets the year. Should be a four-digit year specification.
 public final boolean hasDate() 
    True if this date/time specification specifies a full date (year, month, day)
 public final boolean hasDay() 
    True if this date/time specification specifies a day-of-month.
 public final boolean hasMonth() 
    True if this date/time specification specifies a month-of-year.
 public final boolean hasTime() 
    True if this date/time specification specifies a time-of-day.
 public final boolean hasTimeZone() 
    True if this date/time specification specifies a timezone.
 public final boolean hasYear() 
    True if this date/time specification specifies a year.
 public boolean isImmutable() 
    True if the instance is immutable.
 public boolean isValid() 
    True if all date fields lie within their legal ranges. A GDateBuilder can be invalid, for example, if you change the month to February and the day-of-month is 31.
 static final boolean isValidGDate(GDateSpecification date) 
 static int julianDateForGDate(GDateSpecification date) 
 public  void normalize() 
    Normalizes the instance, ensuring date and time fields are within their normal ranges.

    If no timezone or no time is specified, or if a partial date is specified, this method does nothing, and leaves the timezone information as-is.

    If a time or time and date is specified, this method normalizes the timezone to UTC.

  void normalize24h() 
    Normalizes the instance when hour is 24. If day is present, hour 24 is equivalent to hour 00 next day.
 public  void normalizeToTimeZone(int tzTotalMinutes) 
    Normalizes to a time zone specified by a number of offset minutes rather than sign/hour/minute; for example, normalizeToTimeZone(-60) is the same as normalizeToTimeZone(-1, 1, 0).
 public  void normalizeToTimeZone(int tzSign,
    int tzHour,
    int tzMinute) 
    If the time and timezone are known, this method changes the timezone to the specified UTC offset, altering minutes, hours, day, month, and year as necessary to ensure that the actual described moment in time is the same.

    It is an error to operate on instances without a time or timezone, or with a partially specified date.

 public  void setBuiltinTypeCode(int typeCode) 
 public  void setDate(Date date) 
    Sets the current time and date based on a java.util.Date instance.

    The timezone offset used is based on the default TimeZone. (The default TimeZone is consulted to incorporate daylight savings offsets if applicable for the current date as well as the base timezone offset.)

    If you wish to normalize the timezone, e.g., to UTC, follow this with a call to normalizeToTimeZone.

 public  void setDay(int day) 
    Sets the day-of-month. The first day of each month is 1.
 public  void setGDate(GDateSpecification gdate) 
    Copies a GDateSpecification, completely replacing the current information in this GDateBuilder.
 public  void setJulianDate(int julianday) 
    Sets the Gregorian date based on the given Julian date. The Julian date (JD) is a continuous count of days from 1 January 4713 BC.
 public  void setMonth(int month) 
    Sets the month-of-year. January is 1.
 public  void setTime(int hour,
    int minute,
    int second,
    BigDecimal fraction) 
    Sets the time. Hours in the day range from 0 to 23; minutes and seconds range from 0 to 59; and fractional seconds range from 0 (inclusive) to 1 (exclusive). The fraction can be null and is assumed to be zero.
 public  void setTimeZone(int tzTotalMinutes) 
    Sets the time zone based on a number of offset minutes rather than sign/hour/minute; for example, setTimeZone(-60) is the same as setTimeZone(-1, 1, 0).
 public  void setTimeZone(int tzSign,
    int tzHour,
    int tzMinute) 
    Sets the time zone without changing the other time fields. If you with to adjust other time fields to express the same actual moment in time in a different time zone, use normalizeToTimeZone.

    Timezones must be between -14:00 and +14:00. Sign must be -1 or 1 (or 0 for UTC only), and the offset hours and minute arguments must be nonnegative.

 public  void setYear(int year) 
    Sets the year. Should be a four-digit year specification.
 public  void subtractGDuration(GDurationSpecification duration) 
    Subtracts a given duration from the date/time.
 public GDate toGDate() 
    Builds a GDate from this GDateBuilder.
 public final 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.