public final class StartOfYear extends java.lang.Object implements java.lang.Comparable<StartOfYear>, java.io.Serializable
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
| Constructor and Description |
|---|
StartOfYear(int monthOfYearWithJanAs1,
int dayOfMonth)
Constructs a
StartOfYear object specifying a definition of
"years" that begin on the specified first day of the year. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(StartOfYear comparisonStartOfYear)
Compares this
StartOfYear with the specified comparison
StartOfYear for chronological order. |
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 (January) and 12 (December) 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). |
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.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.
If monthOfYear() is 2 (for February), this
dayOfMonth() will never be greater than 28, as February 29th
only exists in leap years, and StartOfYear has to be
applicable to all years.
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.toString()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.ObjectfromString(java.lang.String)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.Objectpublic int hashCode()
equals.hashCode in class java.lang.Objectpublic int compareTo(StartOfYear comparisonStartOfYear)
StartOfYear with the specified comparison
StartOfYear for chronological order.compareTo in interface java.lang.Comparable<StartOfYear>comparisonStartOfYear - the StartOfYear to be compared.
Cannot be null.StartOfYear is before
comparisonStartOfYear; zero if this
StartOfYear is equal to
comparisonStartOfYear; or a positive integer if this
StartOfYear is after
comparisonStartOfYear.java.lang.NullPointerException - if comparisonStartOfYear is
null.
See www.degreedays.net/api/ for more about the Degree Days.net API.
You can sign up for a Degree Days.net API account and read the integration guide that is useful and applicable whether you are using Java or not.