|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.degreedays.time.StartOfYear
public final class StartOfYear
Specifies a definition of "years" that begin on a specified day of the year (e.g. January 1st for calendar years).
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
Constructor Summary | |
---|---|
StartOfYear(int monthOfYearWithJanAs1,
int dayOfMonth)
Constructs a StartOfYear object specifying a definition of
"years" that begin on the specified first day of the year. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object otherStartOfYear)
|
int |
dayOfMonth()
Returns the number between 1 and the number of days in monthOfYear() (inclusive) indicating which day in
monthOfYear() is the first day of the "year" defined by this
StartOfYear . |
boolean |
equals(java.lang.Object o)
Returns true if o is a StartOfYear
object representing the same day of the year as this ;
false otherwise. |
static StartOfYear |
fromString(java.lang.String startOfYearString)
Parses a string representation of a StartOfYear in
--MM-DD format, the format used by XML Schema's gMonthDay
type (based on ISO 8601). |
int |
hashCode()
Overridden to ensure consistency with equals . |
int |
monthOfYear()
Returns the number between 1 and 12 (inclusive) indicating the month of the calendar year in which the "year" defined by this StartOfYear starts. |
static StartOfYear |
of(int monthOfYearWithJanAs1,
int dayOfMonth)
Returns a non-null StartOfYear object specifying a
definition of "years" that begin on the specified first day of the year. |
java.lang.String |
toString()
Returns a non-null, non-empty string representation of this object in --MM-DD format, the format used by XML Schema's gMonthDay
type (based on ISO 8601). |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StartOfYear(int monthOfYearWithJanAs1, int dayOfMonth)
StartOfYear
object specifying a definition of
"years" that begin on the specified first day of the year.
monthOfYearWithJanAs1
- a number between 1 and 12 (inclusive)
indicating the month of the year in which the "year" should start.
For example, if you're working with UK financial years, choose 4
to specify that your "years" start in April.dayOfMonth
- a number between 1 and the number of days in
monthOfYearWithJanAs1
(inclusive) indicating which
day in monthOfYearWithJanAs1
should be taken as the
first day of the "year". Note that the upper limit for February (
monthOfYearWithJanAs1 == 2
) is 28, not 29, since
February only has 29 days on leap years and a
StartOfYear
must be applicable to all years.
java.lang.IllegalArgumentException
- if monthOfYearWithJanAs1
and/or dayOfMonth
are invalid according to the rules
explained above.Method Detail |
---|
public static StartOfYear of(int monthOfYearWithJanAs1, int dayOfMonth)
StartOfYear
object specifying a
definition of "years" that begin on the specified first day of the year.
monthOfYearWithJanAs1
- a number between 1 and 12 (inclusive)
indicating the month of the year in which the "year" should start.
For example, if you're working with UK financial years, choose 4
to specify that your "years" start in April.dayOfMonth
- a number between 1 and the number of days in
monthOfYearWithJanAs1
(inclusive) indicating which
day in monthOfYearWithJanAs1
should be taken as the
first day of the "year". Note that the upper limit for February (
monthOfYearWithJanAs1 == 2
) is 28, not 29, since
February only has 29 days on leap years and a
StartOfYear
must be applicable to all years.
java.lang.IllegalArgumentException
- if monthOfYearWithJanAs1
and/or dayOfMonth
are invalid according to the rules
explained above.public int monthOfYear()
StartOfYear
starts.
public int dayOfMonth()
monthOfYear()
(inclusive) indicating which day in
monthOfYear()
is the first day of the "year" defined by this
StartOfYear
.
public static StartOfYear fromString(java.lang.String startOfYearString) throws java.lang.NumberFormatException
StartOfYear
in
--MM-DD
format, the format used by XML Schema's gMonthDay
type (based on ISO 8601).
Note that this method will not accept a string containing the time-zone
information that is optionally allowed by XML Schema's gMonthDay type. It
also will not accept "--02-29"
, since that month-day
combination only makes sense on leap years, and StartOfYear
is designed to be applicable to all years.
StartOfYear
object corresponding to the
month-day combination represented by
startOfYearString
.
java.lang.NullPointerException
- if startOfYearString
is
null
.
java.lang.NumberFormatException
- if startOfYearString
has an
invalid format, or represents an impossible month-day
combination.public java.lang.String toString()
--MM-DD
format, the format used by XML Schema's gMonthDay
type (based on ISO 8601).
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
true
if o
is a StartOfYear
object representing the same day of the year as this
;
false
otherwise.
equals
in class java.lang.Object
public int hashCode()
equals
.
hashCode
in class java.lang.Object
public int compareTo(java.lang.Object otherStartOfYear)
compareTo
in interface java.lang.Comparable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |