## org.jfree.data.time
Class Month

    java.lang.Object
      org.jfree.data.time.RegularTimePeriod
          org.jfree.data.time.Month

All Implemented Interfaces:
  java.lang.Comparable, org.jfree.date.MonthConstants, java.io.Serializable, TimePeriod

public class Month
extends RegularTimePeriod
implements java.io.Serializable

Represents a single month.

This class is immutable, which is a requirement for all `RegularTimePeriod` subclasses.

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.jfree.data.time.RegularTimePeriod
`DEFAULT_TIME_ZONE, WORKING_CALENDAR`

Fields inherited from interface org.jfree.date.MonthConstants
`APRIL, AUGUST, DECEMBER, FEBRUARY, JANUARY, JULY, JUNE, MARCH, MAY, NOVEMBER, OCTOBER, SEPTEMBER`

Constructor Summary
`Month()` Constructs a new Month, based on the current system time.
`Month(java.util.Date time)` Constructs a Month, based on a date/time and the default time zone.
`Month(java.util.Date time, java.util.TimeZone zone)` Constructs a Month, based on a date/time and a time zone.
`Month(int month, int year)` Constructs a new month instance.
`Month(int month, Year year)` Constructs a new month instance.

Method Summary
`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(java.util.Calendar calendar)` Returns the first millisecond of the month, evaluated using the supplied calendar (which determines the time zone).
`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.
`RegularTimePeriod` `previous()` Returns the month preceding this one.
`java.lang.String` `toString()` Returns a string representing the month (e.g.

Methods inherited from class org.jfree.data.time.RegularTimePeriod
`getEnd, getFirstMillisecond, getFirstMillisecond, getLastMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getStart`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Month

    public Month()

  Constructs a new Month, based on the current system time.

### Month

    public Month(int month,
                 int year)

  Constructs a new month instance.

Parameters:
  `month` - the month (in the range 1 to 12).
  `year` - the year.

### Month

    public Month(int month,
                 Year year)

  Constructs a new month instance.

Parameters:
  `month` - the month (in the range 1 to 12).
  `year` - the year.

### Month

    public Month(java.util.Date time)

  Constructs a Month, based on a date/time and the default time zone.

Parameters:
  `time` - the date/time.

### Month

    public Month(java.util.Date time,
                 java.util.TimeZone zone)

  Constructs a Month, based on a date/time and a time zone.

Parameters:
  `time` - the date/time.
  `zone` - the time zone.

Method Detail

### getYear

    public Year getYear()

  Returns the year in which the month falls.

  Returns:
    the year in which the month falls (as a Year object).

### getYearValue

    public int getYearValue()

  Returns the year in which the month falls.

  Returns:
    the year in which the monht falls (as an int).

### getMonth

    public int getMonth()

  Returns the month. Note that 1=JAN, 2=FEB, ...

  Returns:
    the month.

### previous

    public RegularTimePeriod previous()

  Returns the month preceding this one.

  Specified by:
    `previous` in class `RegularTimePeriod`
  Returns:
    the month preceding this one.

### next

    public RegularTimePeriod next()

  Returns the month following this one.

  Specified by:
    `next` in class `RegularTimePeriod`
  Returns:
    the month following this one.

### getSerialIndex

    public long getSerialIndex()

  Returns a serial index number for the month.

  Specified by:
    `getSerialIndex` in class `RegularTimePeriod`
  Returns:
    the serial index number.

### toString

    public java.lang.String toString()

  Returns a string representing the month (e.g. "January 2002").

  To do: look at internationalisation.

  Overrides:
    `toString` in class `RegularTimePeriod`
  Returns:
    a string representing the month.

### equals

    public boolean equals(java.lang.Object obj)

  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.

  Parameters:
    `obj` - the object.
  Returns:
    `true` if month and year of this and object are the same.

### hashCode

    public int 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`

  Returns:
    A hash code.

### compareTo

    public 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.

  Specified by:
    `compareTo` in interface `java.lang.Comparable`
  Parameters:
    `o1` - the object to compare.
  Returns:
    negative == before, zero == same, positive == after.

### getFirstMillisecond

    public long getFirstMillisecond(java.util.Calendar calendar)

  Returns the first millisecond of the month, evaluated using the supplied calendar (which determines the time zone).

  Specified by:
    `getFirstMillisecond` in class `RegularTimePeriod`
  Parameters:
    `calendar` - the calendar.
  Returns:
    the first millisecond of the month.

### getLastMillisecond

    public long getLastMillisecond(java.util.Calendar calendar)

  Returns the last millisecond of the month, evaluated using the supplied calendar (which determines the time zone).

  Specified by:
    `getLastMillisecond` in class `RegularTimePeriod`
  Parameters:
    `calendar` - the calendar.
  Returns:
    the last millisecond of the month.

### parseMonth

    public static Month parseMonth(java.lang.String s)

  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.
  Returns:
    `null` if the string is not parseable, the month otherwise.