Class TimePeriod

java.lang.Object
org.jfree.data.time.RegularTimePeriod
net.simplace.core.ui.jfreechart.TimePeriod
All Implemented Interfaces:
Serializable, Comparable, org.jfree.data.time.TimePeriod, org.jfree.date.MonthConstants

public class TimePeriod extends org.jfree.data.time.RegularTimePeriod implements Serializable
Author:
Andreas Enders Represents a year in the range -9999 to 9999. This class is immutable, which is a requirement for all RegularTimePeriod subclasses.
See Also:
  • 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

    Constructors
    Constructor
    Description
    Creates a new Year, based on the current system date/time.
    TimePeriod(Date start, Date end)
    Creates a time period representing a single year.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns an integer indicating the order of this Year object relative to the specified object: negative == before, zero == same, positive == after.
    boolean
    Tests the equality of this Year object to an arbitrary object.
    long
    Returns the first millisecond of the year.
    long
    Returns the first millisecond of the year, evaluated using the supplied calendar (which determines the time zone).
    long
    Returns the last millisecond of the year.
    long
    Returns the last millisecond of the year, evaluated using the supplied calendar (which determines the time zone).
    long
    Returns a serial index number for the year.
    int
    Returns a hash code for this object instance.
    org.jfree.data.time.RegularTimePeriod
     
    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).
    org.jfree.data.time.RegularTimePeriod
     
    Returns a string representing the year..

    Methods inherited from class org.jfree.data.time.RegularTimePeriod

    createInstance, downsize, getEnd, getFirstMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStart

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TimePeriod

      public TimePeriod()
      Creates a new Year, based on the current system date/time.
    • TimePeriod

      public TimePeriod(Date start, Date end)
      Creates a time period representing a single year.
      Parameters:
      start -
      end -
      year - the year.
  • Method Details

    • getFirstMillisecond

      public long getFirstMillisecond()
      Returns the first millisecond of the year. 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.
      Specified by:
      getFirstMillisecond in class org.jfree.data.time.RegularTimePeriod
      Returns:
      The first millisecond of the year.
      See Also:
    • getLastMillisecond

      public long getLastMillisecond()
      Returns the last millisecond of the year. 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.
      Specified by:
      getLastMillisecond in class org.jfree.data.time.RegularTimePeriod
      Returns:
      The last millisecond of the year.
      See Also:
    • peg

      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).
      Specified by:
      peg in class org.jfree.data.time.RegularTimePeriod
      Parameters:
      calendar - the calendar (null not permitted).
      Since:
      1.0.3
    • getSerialIndex

      public long getSerialIndex()
      Returns a serial index number for the year.

      The implementation simply returns the second of the start time number (e.g. 2002).

      Specified by:
      getSerialIndex in class org.jfree.data.time.RegularTimePeriod
      Returns:
      The serial index number.
    • getFirstMillisecond

      public long getFirstMillisecond(Calendar calendar)
      Returns the first millisecond of the year, evaluated using the supplied calendar (which determines the time zone).
      Specified by:
      getFirstMillisecond in class org.jfree.data.time.RegularTimePeriod
      Parameters:
      calendar - the calendar (null not permitted).
      Returns:
      The first millisecond of the year.
      Throws:
      NullPointerException - if calendar is null.
    • getLastMillisecond

      public long getLastMillisecond(Calendar calendar)
      Returns the last millisecond of the year, evaluated using the supplied calendar (which determines the time zone).
      Specified by:
      getLastMillisecond in class org.jfree.data.time.RegularTimePeriod
      Parameters:
      calendar - the calendar (null not permitted).
      Returns:
      The last millisecond of the year.
      Throws:
      NullPointerException - if calendar is null.
    • equals

      public boolean equals(Object obj)
      Tests the equality of this Year object to an arbitrary object. Returns true if the target is a Year instance representing the same year as this object. In all other cases, returns false.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object (null permitted).
      Returns:
      true if the year of this and the 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

      Overrides:
      hashCode in class Object
      Returns:
      A hash code.
    • compareTo

      public int compareTo(Object o1)
      Returns an integer indicating the order of this Year object relative to the specified object: negative == before, zero == same, positive == after.
      Specified by:
      compareTo in interface Comparable
      Parameters:
      o1 - the object to compare.
      Returns:
      negative == before, zero == same, positive == after.
    • toString

      public String toString()
      Returns a string representing the year..
      Overrides:
      toString in class org.jfree.data.time.RegularTimePeriod
      Returns:
      A string representing the year.
    • previous

      public org.jfree.data.time.RegularTimePeriod previous()
      Specified by:
      previous in class org.jfree.data.time.RegularTimePeriod
    • next

      public org.jfree.data.time.RegularTimePeriod next()
      Specified by:
      next in class org.jfree.data.time.RegularTimePeriod