Package org.jfree.data.time
Class Month
java.lang.Object
org.jfree.data.time.RegularTimePeriod
org.jfree.data.time.Month
- All Implemented Interfaces:
Serializable,Comparable,MonthConstants,TimePeriod
Represents a single month. This class is immutable, which is a requirement
for all
RegularTimePeriod subclasses.- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionMonth()Constructs a new Month, based on the current system time.Month(int month, int year) Constructs a new month instance.Constructs a new month instance.Constructs a newMonthinstance, based on a date/time.Constructs a new instance, based on a particular date/time.Creates a newMonthinstance, based on the specified time, zone and locale. -
Method Summary
Modifier and TypeMethodDescriptionintReturns an integer indicating the order of this Month object relative to the specified object: negative == before, zero == same, positive == after.booleanTests the equality of this Month object to an arbitrary object.longReturns the first millisecond of the month.longgetFirstMillisecond(Calendar calendar) Returns the first millisecond of the month, evaluated using the supplied calendar (which determines the time zone).longReturns the last millisecond of the month.longgetLastMillisecond(Calendar calendar) Returns the last millisecond of the month, evaluated using the supplied calendar (which determines the time zone).intgetMonth()Returns the month.longReturns a serial index number for the month.getYear()Returns the year in which the month falls.intReturns the year in which the month falls.inthashCode()Returns a hash code for this object instance.next()Returns the month following this one.static MonthparseMonth(String s) Parses the string argument as a month.voidRecalculates the start date/time and end date/time for this time period relative to the supplied calendar (which incorporates a time zone).previous()Returns the month preceding this one.toString()Returns a string representing the month (e.g.Methods inherited from class org.jfree.data.time.RegularTimePeriod
createInstance, downsize, getCalendarInstance, getEnd, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStart, setCalendarInstancePrototype, setThreadLocalCalendarInstance
-
Constructor Details
-
Month
public Month()Constructs a new Month, based on the current system time. The time zone and locale are determined by the calendar returned byRegularTimePeriod.getCalendarInstance(). -
Month
Constructs a new month instance. The time zone and locale are determined by the calendar returned byRegularTimePeriod.getCalendarInstance().- Parameters:
month- the month (in the range 1 to 12).year- the year.
-
Month
Constructs a new month instance. The time zone and locale are determined by the calendar returned byRegularTimePeriod.getCalendarInstance().- Parameters:
month- the month (in the range 1 to 12).year- the year.
-
Month
Constructs a newMonthinstance, based on a date/time. The time zone and locale are determined by the calendar returned byRegularTimePeriod.getCalendarInstance().- Parameters:
time- the date/time (nullnot permitted).- See Also:
-
Month
Creates a newMonthinstance, based on the specified time, zone and locale.- Parameters:
time- the current time.zone- the time zone.locale- the locale.
-
Month
Constructs a new instance, based on a particular date/time. The time zone and locale are determined by thecalendarparameter.- Parameters:
time- the date/time (nullnot permitted).calendar- the calendar to use for calculations (nullnot permitted).
-
-
Method Details
-
getYear
Returns the year in which the month falls.- Returns:
- The year in which the month falls (as a Year object).
-
getYearValue
Returns the year in which the month falls.- Returns:
- The year in which the month falls (as an int).
-
getMonth
Returns the month. Note that 1=JAN, 2=FEB, ...- Returns:
- The month.
-
getFirstMillisecond
Returns the first millisecond of the month. This will be determined relative to the time zone specified in the constructor, or in the calendar instance passed in the most recent call to thepeg(Calendar)method.- Specified by:
getFirstMillisecondin classRegularTimePeriod- Returns:
- The first millisecond of the month.
- See Also:
-
getLastMillisecond
Returns the last millisecond of the month. This will be determined relative to the time zone specified in the constructor, or in the calendar instance passed in the most recent call to thepeg(Calendar)method.- Specified by:
getLastMillisecondin classRegularTimePeriod- Returns:
- The last millisecond of the month.
- See Also:
-
peg
Recalculates the start date/time and end date/time for this time period relative to the supplied calendar (which incorporates a time zone).- Specified by:
pegin classRegularTimePeriod- Parameters:
calendar- the calendar (nullnot permitted).
-
previous
Returns the month preceding this one. Note that the returnedMonthis "pegged" using the default calendar, obtained withRegularTimePeriod.getCalendarInstance(), irrespective of the time-zone used to peg of the current month (which is not recorded anywhere). See thepeg(Calendar)method.- Specified by:
previousin classRegularTimePeriod- Returns:
- The month preceding this one.
-
next
Returns the month following this one. Note that the returnedMonthis "pegged" using the default calendar, obtained withRegularTimePeriod.getCalendarInstance(), irrespective of the time-zone used to peg of the current month (which is not recorded anywhere). See thepeg(Calendar)method.- Specified by:
nextin classRegularTimePeriod- Returns:
- The month following this one.
-
getSerialIndex
Returns a serial index number for the month.- Specified by:
getSerialIndexin classRegularTimePeriod- Returns:
- The serial index number.
-
toString
Returns a string representing the month (e.g. "January 2002").To do: look at internationalisation.
- Overrides:
toStringin classRegularTimePeriod- Returns:
- A string representing the month.
-
equals
Tests the equality of this Month object to an arbitrary object. Returns true if the target is a Month instance representing the same month as this object. In all other cases, returns false. -
hashCode
Returns a hash code for this object instance. The approach described by Joshua Bloch in "Effective Java" has been used here:http://developer.java.sun.com/developer/Books/effectivejava /Chapter3.pdf -
compareTo
Returns an integer indicating the order of this Month object relative to the specified object: negative == before, zero == same, positive == after.- Specified by:
compareToin interfaceComparable- Parameters:
o1- the object to compare.- Returns:
- negative == before, zero == same, positive == after.
-
getFirstMillisecond
Returns the first millisecond of the month, evaluated using the supplied calendar (which determines the time zone).- Specified by:
getFirstMillisecondin classRegularTimePeriod- Parameters:
calendar- the calendar (nullnot permitted).- Returns:
- The first millisecond of the month.
- Throws:
NullPointerException- ifcalendarisnull.- See Also:
-
getLastMillisecond
Returns the last millisecond of the month, evaluated using the supplied calendar (which determines the time zone).- Specified by:
getLastMillisecondin classRegularTimePeriod- Parameters:
calendar- the calendar (nullnot permitted).- Returns:
- The last millisecond of the month.
- Throws:
NullPointerException- ifcalendarisnull.- See Also:
-
parseMonth
Parses the string argument as a month. This method is required to accept the format "YYYY-MM". It will also accept "MM-YYYY". Anything else, at the moment, is a bonus.- Parameters:
s- the string to parse (nullpermitted).- Returns:
nullif the string is not parseable, the month otherwise.
-