public class SimpleTimePeriod extends java.lang.Object implements TimePeriod, java.lang.Comparable, java.io.Serializable
java.util.Date.
This class is intentionally immutable (that is, once constructed, you cannot alter the start and end attributes).
| Modifier and Type | Field and Description |
|---|---|
private long |
end
The end date/time.
|
private static long |
serialVersionUID
For serialization.
|
private long |
start
The start date/time.
|
| Constructor and Description |
|---|
SimpleTimePeriod(java.util.Date start,
java.util.Date end)
Creates a new time allocation.
|
SimpleTimePeriod(long start,
long end)
Creates a new time allocation.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object obj)
Returns an integer that indicates the relative ordering of two
time periods.
|
boolean |
equals(java.lang.Object obj)
Tests this time period instance for equality with an arbitrary object.
|
java.util.Date |
getEnd()
Returns the end date/time.
|
long |
getEndMillis()
Returns the end date/time in milliseconds.
|
java.util.Date |
getStart()
Returns the start date/time.
|
long |
getStartMillis()
Returns the start date/time in milliseconds.
|
int |
hashCode()
Returns a hash code for this object instance.
|
private static final long serialVersionUID
private long start
private long end
public SimpleTimePeriod(long start,
long end)
start - the start date/time in milliseconds.end - the end date/time in milliseconds.public SimpleTimePeriod(java.util.Date start,
java.util.Date end)
start - the start date/time (null not permitted).end - the end date/time (null not permitted).public java.util.Date getStart()
getStart in interface TimePeriodnull).public long getStartMillis()
public java.util.Date getEnd()
getEnd in interface TimePeriodnull).public long getEndMillis()
public boolean equals(java.lang.Object obj)
TimePeriod
and it has the same start and end dates.equals in class java.lang.Objectobj - the other object (null permitted).public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparableobj - the object (null not permitted).java.lang.ClassCastException - if obj is not an instance of
TimePeriod.public int hashCode()
http://developer.java.sun.com/
developer/Books/effectivejava/Chapter3.pdf
hashCode in class java.lang.Object