net.degreedays.time
Class StartOfMonth

java.lang.Object
  extended by net.degreedays.time.StartOfMonth
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public final class StartOfMonth
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Specifies a definition of "months" that begin on a specified day of the month (e.g. 1 for calendar months).

Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.


Constructor Summary
StartOfMonth(int dayOfMonth)
          Constructs a StartOfMonth object specifying a definition of "months" that begin on the specified day of the month.
 
Method Summary
 int compareTo(java.lang.Object anotherStartOfMonth)
           
 int dayOfMonth()
          Returns a number between 1 and 28 (inclusive) indicating which day should be taken as the first of the month.
 boolean equals(java.lang.Object o)
          Returns true if o is a StartOfMonth object representing the same day in the month as this; false otherwise.
static StartOfMonth fromString(java.lang.String startOfMonthString)
          Parses a string representation of a StartOfMonth in ---DD format, the format used by XML Schema's gDay type (based on ISO 8601).
 int hashCode()
          Overridden to ensure consistency with equals.
static StartOfMonth of(int dayOfMonth)
          Returns a non-null StartOfMonth object specifying a definition of "months" that begin on the specified day of the month.
 java.lang.String toString()
          Returns a non-null, non-empty string representation of this object in ---DD format, the format used by XML Schema's gDay type (based on ISO 8601).
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StartOfMonth

public StartOfMonth(int dayOfMonth)
Constructs a StartOfMonth object specifying a definition of "months" that begin on the specified day of the month.

Parameters:
dayOfMonth - a number between 1 and 28 (inclusive) indicating which day should be taken as the start of the "month". Pass 1 to specify regular calendar months.
Throws:
java.lang.IllegalArgumentException - if dayOfMonth is less than 1 or greater than 28.
Method Detail

of

public static StartOfMonth of(int dayOfMonth)
Returns a non-null StartOfMonth object specifying a definition of "months" that begin on the specified day of the month.

Parameters:
dayOfMonth - a number between 1 and 28 (inclusive) indicating which day should be taken as the start of the "month". Pass 1 to specify regular calendar months.
Throws:
java.lang.IllegalArgumentException - if dayOfMonth is less than 1 or greater than 28.

dayOfMonth

public int dayOfMonth()
Returns a number between 1 and 28 (inclusive) indicating which day should be taken as the first of the month.


fromString

public static StartOfMonth fromString(java.lang.String startOfMonthString)
                               throws java.lang.NumberFormatException
Parses a string representation of a StartOfMonth in ---DD format, the format used by XML Schema's gDay type (based on ISO 8601).

Note that, since StartOfMonth is designed to be applicable to all months of all years, this method will not accept "---29", "---30", or "---31".

Parameters:
startOfMonthString - a string with format ---DD, where DD is a number between 01 and 28 (inclusive).
Returns:
a non-null StartOfMonth object corresponding to the day of the month represented by startOfMonthString.
Throws:
java.lang.NullPointerException - if startOfMonthString is null.
java.lang.NumberFormatException - if startOfMonthString has an invalid format, or represents an day of the month that is greater than 28.

toString

public java.lang.String toString()
Returns a non-null, non-empty string representation of this object in ---DD format, the format used by XML Schema's gDay type (based on ISO 8601).

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Returns true if o is a StartOfMonth object representing the same day in the month as this; false otherwise.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overridden to ensure consistency with equals.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object anotherStartOfMonth)
Specified by:
compareTo in interface java.lang.Comparable


www.degreedays.net/api/