Package org.jfree.data.time
Class RegularTimePeriod
java.lang.Object
org.jfree.data.time.RegularTimePeriod
- All Implemented Interfaces:
Comparable,TimePeriod,org.jfree.date.MonthConstants
- Direct Known Subclasses:
Day,FixedMillisecond,Hour,Millisecond,Minute,Month,Quarter,Second,Week,Year
public abstract class RegularTimePeriod extends Object implements TimePeriod, Comparable, org.jfree.date.MonthConstants
An abstract class representing a unit of time.
Convenient methods are provided for calculating the next and previous time periods.
Conversion methods are defined that return the first and last milliseconds of the time period. The results from these methods are timezone dependent.
This class is immutable, and all subclasses should be immutable also.
-
Field Summary
Fields Modifier and Type Field Description static TimeZoneDEFAULT_TIME_ZONEThe default time zone.static CalendarWORKING_CALENDARA working calendar (recycle to avoid unnecessary object creation).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 RegularTimePeriod() -
Method Summary
Modifier and Type Method Description DategetEnd()Returns the date/time that marks the end of the time period.longgetFirstMillisecond()Returns the first millisecond of the time period, evaluated in the default time zone.abstract longgetFirstMillisecond(Calendar calendar)Returns the first millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).longgetFirstMillisecond(TimeZone zone)Returns the first millisecond of the time period, evaluated within a specific time zone.longgetLastMillisecond()Returns the last millisecond of the time period, evaluated in the default time zone.abstract longgetLastMillisecond(Calendar calendar)Returns the last millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).longgetLastMillisecond(TimeZone zone)Returns the last millisecond of the time period, evaluated within a specific time zone.longgetMiddleMillisecond()Returns the millisecond closest to the middle of the time period, evaluated in the default time zone.longgetMiddleMillisecond(Calendar calendar)Returns the millisecond closest to the middle of the time period, evaluated using the supplied calendar (which incorporates a timezone).longgetMiddleMillisecond(TimeZone zone)Returns the millisecond closest to the middle of the time period, evaluated within a specific time zone.abstract longgetSerialIndex()Returns a serial index number for the time unit.DategetStart()Returns the date/time that marks the start of the time period.abstract RegularTimePeriodnext()Returns the time period following this one, or null if some limit has been reached.abstract RegularTimePeriodprevious()Returns the time period preceding this one, or null if some lower limit has been reached.StringtoString()Returns a string representation of the time period.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
DEFAULT_TIME_ZONE
The default time zone. -
WORKING_CALENDAR
A working calendar (recycle to avoid unnecessary object creation).
-
-
Constructor Details
-
RegularTimePeriod
public RegularTimePeriod()
-
-
Method Details
-
previous
Returns the time period preceding this one, or null if some lower limit has been reached.- Returns:
- the previous time period.
-
next
Returns the time period following this one, or null if some limit has been reached.- Returns:
- the next time period.
-
getSerialIndex
public abstract long getSerialIndex()Returns a serial index number for the time unit.- Returns:
- the serial index number.
-
getStart
Returns the date/time that marks the start of the time period.- Specified by:
getStartin interfaceTimePeriod- Returns:
- the start date/time.
-
getEnd
Returns the date/time that marks the end of the time period.- Specified by:
getEndin interfaceTimePeriod- Returns:
- the end date/time.
-
getFirstMillisecond
public long getFirstMillisecond()Returns the first millisecond of the time period, evaluated in the default time zone.- Returns:
- the first millisecond of the time period.
-
getFirstMillisecond
Returns the first millisecond of the time period, evaluated within a specific time zone.- Parameters:
zone- the time zone.- Returns:
- the first millisecond of the time period.
-
getFirstMillisecond
Returns the first millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).- Parameters:
calendar- the calendar.- Returns:
- the first millisecond of the time period.
-
getLastMillisecond
public long getLastMillisecond()Returns the last millisecond of the time period, evaluated in the default time zone.- Returns:
- the last millisecond of the time period.
-
getLastMillisecond
Returns the last millisecond of the time period, evaluated within a specific time zone.- Parameters:
zone- the time zone.- Returns:
- the last millisecond of the time period.
-
getLastMillisecond
Returns the last millisecond of the time period, evaluated using the supplied calendar (which incorporates a timezone).- Parameters:
calendar- the calendar.- Returns:
- the last millisecond of the time period.
-
getMiddleMillisecond
public long getMiddleMillisecond()Returns the millisecond closest to the middle of the time period, evaluated in the default time zone.- Returns:
- The middle millisecond.
-
getMiddleMillisecond
Returns the millisecond closest to the middle of the time period, evaluated within a specific time zone.- Parameters:
zone- the time zone.- Returns:
- The middle millisecond.
-
getMiddleMillisecond
Returns the millisecond closest to the middle of the time period, evaluated using the supplied calendar (which incorporates a timezone).- Parameters:
calendar- the calendar.- Returns:
- The middle millisecond.
-
toString
Returns a string representation of the time period.
-