Year Class
- public class Year
extends Century
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.
The schema type 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 year is the set of Gregorian calendar years
specified as CCYY.
Example: 2001
.
-
Hierarchy
-
Object
Century
Year
-
All Implemented Interfaces
-
Cloneable
, Comparable
, Serializable
-
Direct Known Subclasses
-
Month
-
Year()
- Constructs a new Year instance.
|
-
Year(long year,
TimeZone timeZone)
- Constructs a new Year for the given year and
timezone.
|
public Object |
-
clone ()
- Returns a copy of this Year.
|
public int |
-
compareTo (Year anotherYear)
Compares this Year to another Year object (represented in
the same time zone) in their canonical representation.
|
public int |
-
compareTo (Object anotherObject)
- Compares this Year another object.
|
public static Year |
-
createYear ()
- Returns a Year instance for the current year.
|
public static Year |
-
createYear (String year)
Given a string of the form CCYY, returns a
Year instance.
|
public long |
-
getYear ()
- Returns the year (CCYY) field
|
public void |
-
setYear (int century, int year)
- Sets the year (CCYY) field
|
public void |
-
setYear (long year)
- Sets the year (CCYY) field
|
public String |
-
toString ()
Returns a XML schema compliant year string.
|
public Object |
-
toUTC ()
- Offsets the current month instant to UTC.
|
Methods from com.bea.p13n.xml.schema.Century |
compareTo , createCentury , createCentury , getCentury , getEra , getTimeZone , setCentury , setEra , setTimeZone , setTimeZone ,
|
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Year
protected Year()
- Constructs a new Year instance.
Year
protected Year(long year,
TimeZone
timeZone)
- Constructs a new Year for the given year and
timezone. The year argument should include the century.
clone() Method
public Object
clone()
Returns a copy of this Year.
-
Overrides
-
Century.clone()
Returns
- copy
compareTo(Year) Method
public int compareTo(Year
anotherYear)
Compares this Year to another Year object (represented in
the same time zone) in their canonical representation.
Parameters
-
anotherYear
- another Year object to be compared.
Returns
- the value 0 if the argument Year is equal to
this Year; a value less than 0 if this Year is
before the Year argument; and a value greater than 0 if
this Year is after the Year argument.
compareTo(Object) Method
public int compareTo(Object
anotherObject)
Compares this Year another object. If the other object is a
Year, this method behaves like compareTo(Year). Otherwise, it
throws a ClassCastException.
-
Overrides
-
Century.compareTo(Object)
Parameters
-
anotherObject
- the object to be compared
Returns
- the value 0 if the argument Year is equal to
this Year; a value less than 0 if this Year is
before the Year argument; and a value greater than 0 if
this Year is after the Year argument.
createYear() Method
public static Year
createYear()
Returns a Year instance for the current year.
Returns
- instance of Year
createYear(String) Method
public static Year
createYear(String
year)
throws ParseException
Given a string of the form CCYY, returns a
Year instance.
The argument may optionally include a timezone.
Returns
- instance of Year
Exceptions
-
ParseException
getYear() Method
public long getYear()
Returns the year (CCYY) field
Returns
- the year
setYear(int, int) Method
public void setYear(int century,
int year)
throws IllegalArgumentException
Sets the year (CCYY) field
Parameters
-
century
- the century (CC)
-
year
- the year (YY)
Exceptions
-
IllegalArgumentException
- thrown when the century and
year arguments are illegal
setYear(long) Method
public void setYear(long year)
Sets the year (CCYY) field
Parameters
-
year
- year (CCYY)
toString() Method
public String
toString()
Returns a XML schema compliant year string.
-
Overrides
-
Century.toString()
Returns
- string value
toUTC() Method
public Object
toUTC()
Offsets the current month instant to UTC.
-
Overrides
-
Century.toUTC()
Returns
- instance of Year offset to UTC