Century Class

com.bea.p13n.xml.schema
Century Class

public class Century

    extends Object
    implements Cloneable, Comparable, Serializable

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


Hierarchy
Object
  Century
All Implemented Interfaces

Cloneable, Comparable, Serializable
Direct Known Subclasses

Year

Field Summary

protected TimePeriod
_internal
TimePeriod
 

Constructor Summary

Century()

Constructs a new Century instance.
Century(long century, TimeZone timeZone)

Constructs a new Century for the given century and timezone.
 

Method Summary

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

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

public int
compareTo(Object anotherObject)
Compares this Century another object.
public static Century
createCentury()
Returns a Century instance for the current century.
public static Century
createCentury(String century)

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

public long
getCentury()
Returns the year (CC) field
public int
getEra()
Returns the era (+/-)
public TimeZone
getTimeZone()
Returns the time zone
public void
setCentury(long century)
Sets the year (CCYY) field
public void
setEra(int era)
Sets the era (+/-)
public void
setTimeZone(int zoneHour, int zoneMinute)
Sets the time zone
public void
setTimeZone(TimeZone timeZone)
Sets the time zone
public String
toString()

Returns a XML schema compliant year string.

public Object
toUTC()
Offsets the current century instant to UTC.
 
Methods from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
   
Methods from interface java.lang.Comparable
compareTo
 

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() Method

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

Overrides
Object.clone()

Returns

copy

compareTo(Century) Method

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.

compareTo(Object) Method

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.

Parameters

anotherObject
the 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.

createCentury() Method

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

Returns

instance of Century

createCentury(String) Method

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

Exceptions

ParseException

getCentury() Method

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

Returns

the year

getEra() Method

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

Returns

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

getTimeZone() Method

public TimeZone getTimeZone()
Returns the time zone

Returns

timeZone the time zone

setCentury(long) Method

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

Parameters

century
the century (CC)

Exceptions

IllegalArgumentException
thrown when the century and year arguments are illegal

setEra(int) Method

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

Parameters

era
the era (+/-)

setTimeZone(int, int) Method

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(TimeZone) Method

public void setTimeZone(TimeZone timeZone)
Sets the time zone

Parameters

timeZone
an instance java.util.TimeZone

toString() Method

public String toString()

Returns a XML schema compliant year string.

Overrides
Object.toString()

Returns

string value

toUTC() Method

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

Returns

instance of Century offset to UTC