Package org.jfree.data.time
Class SimpleTimePeriod
- java.lang.Object
-
- org.jfree.data.time.SimpleTimePeriod
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable,TimePeriod
public class SimpleTimePeriod extends java.lang.Object implements TimePeriod, java.lang.Comparable, java.io.Serializable
An arbitrary period of time, measured to millisecond precision usingjava.util.Date.This class is intentionally immutable (that is, once constructed, you cannot alter the start and end attributes).
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private longendThe end date/time.private static longserialVersionUIDFor serialization.private longstartThe start date/time.
-
Constructor Summary
Constructors Constructor Description SimpleTimePeriod(long start, long end)Creates a new time allocation.SimpleTimePeriod(java.util.Date start, java.util.Date end)Creates a new time allocation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object obj)Returns an integer that indicates the relative ordering of two time periods.booleanequals(java.lang.Object obj)Tests this time period instance for equality with an arbitrary object.java.util.DategetEnd()Returns the end date/time.longgetEndMillis()Returns the end date/time in milliseconds.java.util.DategetStart()Returns the start date/time.longgetStartMillis()Returns the start date/time in milliseconds.inthashCode()Returns a hash code for this object instance.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
start
private long start
The start date/time.
-
end
private long end
The end date/time.
-
-
Constructor Detail
-
SimpleTimePeriod
public SimpleTimePeriod(long start, long end)Creates a new time allocation.- Parameters:
start- the start date/time in milliseconds.end- the end date/time in milliseconds.
-
SimpleTimePeriod
public SimpleTimePeriod(java.util.Date start, java.util.Date end)Creates a new time allocation.- Parameters:
start- the start date/time (nullnot permitted).end- the end date/time (nullnot permitted).
-
-
Method Detail
-
getStart
public java.util.Date getStart()
Returns the start date/time.- Specified by:
getStartin interfaceTimePeriod- Returns:
- The start date/time (never
null).
-
getStartMillis
public long getStartMillis()
Returns the start date/time in milliseconds.- Returns:
- The start.
-
getEnd
public java.util.Date getEnd()
Returns the end date/time.- Specified by:
getEndin interfaceTimePeriod- Returns:
- The end date/time (never
null).
-
getEndMillis
public long getEndMillis()
Returns the end date/time in milliseconds.- Returns:
- The end.
-
equals
public boolean equals(java.lang.Object obj)
Tests this time period instance for equality with an arbitrary object. The object is considered equal if it is an instance ofTimePeriodand it has the same start and end dates.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the other object (nullpermitted).- Returns:
- A boolean.
-
compareTo
public int compareTo(java.lang.Object obj)
Returns an integer that indicates the relative ordering of two time periods.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
obj- the object (nullnot permitted).- Returns:
- An integer.
- Throws:
java.lang.ClassCastException- ifobjis not an instance ofTimePeriod.
-
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 - see:http://developer.java.sun.com/ developer/Books/effectivejava/Chapter3.pdf- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
-