public class

Month

extends RegularTimePeriod
implements Serializable
java.lang.Object
   ↳ org.jfree.data.time.RegularTimePeriod
     ↳ org.jfree.data.time.Month

Class Overview

Represents a single month. This class is immutable, which is a requirement for all RegularTimePeriod subclasses.

Summary

[Expand]
Inherited Fields
From class org.jfree.data.time.RegularTimePeriod
Public Constructors
Month()
Constructs a new Month, based on the current system time.
Month(int month, int year)
Constructs a new month instance.
Month(int month, Year year)
Constructs a new month instance.
Month(Date time)
Constructs a new Month instance, based on a date/time and the default time zone.
Month(Date time, TimeZone zone)
This constructor is deprecated. Since 1.0.12, use Month(Date, TimeZone, Locale) instead.
Month(Date time, TimeZone zone, Locale locale)
Creates a new Month instance, based on the specified time, zone and locale.
Public Methods
int compareTo(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(Object obj)
Tests the equality of this Month object to an arbitrary object.
long getFirstMillisecond(Calendar calendar)
Returns the first millisecond of the month, evaluated using the supplied calendar (which determines the time zone).
long getFirstMillisecond()
Returns the first millisecond of the month.
long getLastMillisecond(Calendar calendar)
Returns the last millisecond of the month, evaluated using the supplied calendar (which determines the time zone).
long getLastMillisecond()
Returns the last millisecond of the month.
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(String s)
Parses the string argument as a month.
void peg(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.
String toString()
Returns a string representing the month (e.g.
[Expand]
Inherited Methods
From class org.jfree.data.time.RegularTimePeriod
From class java.lang.Object
From interface java.lang.Comparable
From interface org.jfree.data.time.TimePeriod

Public Constructors

public Month ()

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

public Month (int month, int year)

Constructs a new month instance.

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

public Month (int month, Year year)

Constructs a new month instance.

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

public Month (Date time)

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

Parameters
time the date/time (null not permitted).

public Month (Date time, TimeZone zone)

This constructor is deprecated.
Since 1.0.12, use Month(Date, TimeZone, Locale) instead.

Constructs a new 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.

Parameters
time the date/time.
zone the time zone (null not permitted).

public Month (Date time, TimeZone zone, Locale locale)

Creates a new Month instance, based on the specified time, zone and locale.

Parameters
time the current time.
zone the time zone.
locale the locale.

Public Methods

public int compareTo (Object o1)

Returns an integer indicating the order of this Month object relative to the specified object: negative == before, zero == same, positive == after.

Parameters
o1 the object to compare.
Returns
  • negative == before, zero == same, positive == after.

public boolean equals (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 (null permitted).
Returns
  • true if month and year of this and object are the same.

public long getFirstMillisecond (Calendar calendar)

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

Parameters
calendar the calendar (null not permitted).
Returns
  • The first millisecond of the month.
Throws
NullPointerException if calendar is null.

public long 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 the peg(Calendar) method.

Returns
  • The first millisecond of the month.

public long getLastMillisecond (Calendar calendar)

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

Parameters
calendar the calendar (null not permitted).
Returns
  • The last millisecond of the month.
Throws
NullPointerException if calendar is null.

public long 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 the peg(Calendar) method.

Returns
  • The last millisecond of the month.

public int getMonth ()

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

Returns
  • The month.

public long getSerialIndex ()

Returns a serial index number for the month.

Returns
  • The serial index number.

public Year getYear ()

Returns the year in which the month falls.

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

public int getYearValue ()

Returns the year in which the month falls.

Returns
  • The year in which the month falls (as an int).

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.

public RegularTimePeriod next ()

Returns the month following this one. Note that the returned 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.

Returns
  • The month following this one.

public static Month parseMonth (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 (null permitted).
Returns
  • null if the string is not parseable, the month otherwise.

public void peg (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).

Parameters
calendar the calendar (null not permitted).

public RegularTimePeriod previous ()

Returns the month preceding this one. Note that the returned 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.

Returns
  • The month preceding this one.

public String toString ()

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

To do: look at internationalisation.

Returns
  • A string representing the month.