public class Month extends RegularTimePeriod implements java.io.Serializable
RegularTimePeriod
subclasses.DEFAULT_TIME_ZONE, WORKING_CALENDAR
Constructor and Description |
---|
Month()
Constructs a new Month, based on the current system time.
|
Month(java.util.Date time)
Constructs a new
Month instance, based on a date/time and
the default time zone. |
Month(java.util.Date time,
java.util.TimeZone zone)
Deprecated.
Since 1.0.12, use
Month(Date, TimeZone, Locale)
instead. |
Month(java.util.Date time,
java.util.TimeZone zone,
java.util.Locale locale)
Creates a new
Month instance, based on the specified time,
zone and locale. |
Month(int month,
int year)
Constructs a new month instance.
|
Month(int month,
Year year)
Constructs a new month instance.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o1)
Returns an integer indicating the order of this Month object relative to
the specified
object: negative == before, zero == same, positive == after.
|
boolean |
equals(java.lang.Object obj)
Tests the equality of this Month object to an arbitrary object.
|
long |
getFirstMillisecond()
Returns the first millisecond of the month.
|
long |
getFirstMillisecond(java.util.Calendar calendar)
Returns the first millisecond of the month, evaluated using the supplied
calendar (which determines the time zone).
|
long |
getLastMillisecond()
Returns the last millisecond of the month.
|
long |
getLastMillisecond(java.util.Calendar calendar)
Returns the last millisecond of the month, evaluated using the supplied
calendar (which determines the time zone).
|
int |
getMonth()
Returns the month.
|
long |
getSerialIndex()
Returns a serial index number for the month.
|
Year |
getYear()
Returns the year in which the month falls.
|
int |
getYearValue()
Returns the year in which the month falls.
|
int |
hashCode()
Returns a hash code for this object instance.
|
RegularTimePeriod |
next()
Returns the month following this one.
|
static Month |
parseMonth(java.lang.String s)
Parses the string argument as a month.
|
void |
peg(java.util.Calendar calendar)
Recalculates the start date/time and end date/time for this time period
relative to the supplied calendar (which incorporates a time zone).
|
RegularTimePeriod |
previous()
Returns the month preceding this one.
|
java.lang.String |
toString()
Returns a string representing the month (e.g.
|
createInstance, downsize, getEnd, getFirstMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStart
public Month()
public Month(int month, int year)
month
- the month (in the range 1 to 12).year
- the year.public Month(int month, Year year)
month
- the month (in the range 1 to 12).year
- the year.public Month(java.util.Date time)
Month
instance, based on a date/time and
the default time zone.time
- the date/time (null
not permitted).Month(Date, TimeZone)
public Month(java.util.Date time, java.util.TimeZone zone)
Month(Date, TimeZone, Locale)
instead.Month
instance, based on a date/time and
a time zone. The first and last millisecond values are initially
pegged to the given time zone also.time
- the date/time.zone
- the time zone (null
not permitted).public Month(java.util.Date time, java.util.TimeZone zone, java.util.Locale locale)
Month
instance, based on the specified time,
zone and locale.time
- the current time.zone
- the time zone.locale
- the locale.public Year getYear()
public int getYearValue()
public int getMonth()
public long getFirstMillisecond()
peg(Calendar)
method.getFirstMillisecond
in class RegularTimePeriod
getLastMillisecond()
public long getLastMillisecond()
peg(Calendar)
method.getLastMillisecond
in class RegularTimePeriod
getFirstMillisecond()
public void peg(java.util.Calendar calendar)
peg
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).public RegularTimePeriod previous()
Month
is "pegged" using the default time-zone, irrespective of
the time-zone used to peg of the current month (which is not recorded
anywhere). See the peg(Calendar)
method.previous
in class RegularTimePeriod
public RegularTimePeriod next()
Month
is "pegged" using the default time-zone, irrespective of
the time-zone used to peg of the current month (which is not recorded
anywhere). See the peg(Calendar)
method.next
in class RegularTimePeriod
public long getSerialIndex()
getSerialIndex
in class RegularTimePeriod
public java.lang.String toString()
To do: look at internationalisation.
toString
in class RegularTimePeriod
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object (null
permitted).true
if month and year of this and object are the
same.public int hashCode()
http://developer.java.sun.com/developer/Books/effectivejava
/Chapter3.pdf
hashCode
in class java.lang.Object
public int compareTo(java.lang.Object o1)
compareTo
in interface java.lang.Comparable
o1
- the object to compare.public long getFirstMillisecond(java.util.Calendar calendar)
getFirstMillisecond
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).java.lang.NullPointerException
- if calendar
is
null
.RegularTimePeriod.getLastMillisecond(Calendar)
public long getLastMillisecond(java.util.Calendar calendar)
getLastMillisecond
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).java.lang.NullPointerException
- if calendar
is
null
.RegularTimePeriod.getFirstMillisecond(Calendar)
public static Month parseMonth(java.lang.String s)
s
- the string to parse (null
permitted).null
if the string is not parseable, the month
otherwise.