© 2005 BEA Systems, Inc.

com.bea.p13n.xml.schema
Class Century

java.lang.Object
  extended bycom.bea.p13n.xml.schema.Century
All Implemented Interfaces:
Cloneable, Comparable, Serializable
Direct Known Subclasses:
Year

public class Century
extends Object
implements Serializable, Cloneable, Comparable

This class provides the Java biding for the XML schema type year as specified in Section 3.3.29 of XML Schema Part 2: Datatypes.

year represents a specific period of time that starts at the midnight that starts of the first day of the year and ends at the midnight that ends the last day of the year.

The value space of century is the set of Gregorian calendar centuries specified as CC.

Example: 21 for 21st century

See Also:
Serialized Form

Field Summary
protected  TimePeriod _internal
           
 
Constructor Summary
protected Century()
          Constructs a new Century instance.
protected Century(long century, TimeZone timeZone)
          Constructs a new Century for the given century and timezone.
 
Method Summary
 Object clone()
          Returns a copy of this Century.
 int compareTo(Century anotherCentury)
          Compares this Century to another Century object (represented in the same time zone) in their canonical representation.
 int compareTo(Object anotherObject)
          Compares this Century another object.
static Century createCentury()
          Returns a Century instance for the current century.
static Century createCentury(String century)
          Given a string of the form CC, returns a Century instance.
 long getCentury()
          Returns the year (CC) field
 int getEra()
          Returns the era (+/-)
 TimeZone getTimeZone()
          Returns the time zone
 void setCentury(long century)
          Sets the year (CCYY) field
 void setEra(int era)
          Sets the era (+/-)
 void setTimeZone(int zoneHour, int zoneMinute)
          Sets the time zone
 void setTimeZone(TimeZone timeZone)
          Sets the time zone
 String toString()
          Returns a XML schema compliant year string.
 Object toUTC()
          Offsets the current century instant to UTC.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_internal

protected TimePeriod _internal
Constructor Detail

Century

protected Century()
Constructs a new Century instance.


Century

protected Century(long century,
                  TimeZone timeZone)
Constructs a new Century for the given century and timezone.

Method Detail

clone

public Object clone()
Returns a copy of this Century.

Returns:
copy

compareTo

public int compareTo(Century anotherCentury)

Compares this Century to another Century object (represented in the same time zone) in their canonical representation.

Parameters:
anotherCentury - another Century object to be compared.
Returns:
the value 0 if the argument Century is equal to this Century; a value less than 0 if this Century is before the Century argument; and a value greater than 0 if this Century is after the Century argument.
Throws:
IllegalArgumentException - thrown when the argument is represented in a different time zone from the current year.

compareTo

public int compareTo(Object anotherObject)
Compares this Century another object. If the other object is a Century, this method behaves like compareTo(Century). Otherwise, it throws a ClassCastException.

Specified by:
compareTo in interface Comparable
Returns:
the value 0 if the argument Century is equal to this Century; a value less than 0 if this Century is before the Century argument; and a value greater than 0 if this Century is after the Century argument.
Throws:
ClassCastException - thrown if the argument is not an instance of Year.

createCentury

public static Century createCentury()
Returns a Century instance for the current century.

Returns:
instance of Century

createCentury

public static Century createCentury(String century)
                             throws ParseException

Given a string of the form CC, returns a Century instance.

The argument may optionally include a timezone.

Returns:
instance of Century
Throws:
ParseException - thrown due to illegal string argument.

getCentury

public long getCentury()
Returns the year (CC) field

Returns:
the year

getEra

public int getEra()
Returns the era (+/-)

Returns:
the era (one of java.util.GregorianCalendar.AD or java.util.GregorianCalendar.BC)

getTimeZone

public TimeZone getTimeZone()
Returns the time zone

Returns:
timeZone the time zone

setCentury

public void setCentury(long century)
                throws IllegalArgumentException
Sets the year (CCYY) field

Parameters:
century - the century (CC)
Throws:
IllegalArgumentException - thrown when the century and year arguments are illegal

setEra

public void setEra(int era)
Sets the era (+/-)

Parameters:
era - the era (+/-)

setTimeZone

public void setTimeZone(int zoneHour,
                        int zoneMinute)
Sets the time zone

Parameters:
zoneHour - the hour field of timeZone. Can be negative to indicate negative offset.
zoneMinute - the minute field of timeZone

setTimeZone

public void setTimeZone(TimeZone timeZone)
Sets the time zone

Parameters:
timeZone - an instance java.util.TimeZone

toString

public String toString()

Returns a XML schema compliant year string.

Returns:
string value

toUTC

public Object toUTC()
Offsets the current century instant to UTC.

Returns:
instance of Century offset to UTC

© 2005 BEA Systems, Inc.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved