com.jrefinery.data
Class Millisecond

java.lang.Object
  |
  +--com.jrefinery.data.TimePeriod
        |
        +--com.jrefinery.data.Millisecond
All Implemented Interfaces:
java.lang.Comparable, com.jrefinery.date.MonthConstants

public class Millisecond
extends TimePeriod

Represents a millisecond.

This class is immutable, which is a requirement for all TimePeriod subclasses.

Author:
DG

Field Summary
static int FIRST_MILLISECOND_IN_SECOND
          A constant for the first millisecond in a second.
static int LAST_MILLISECOND_IN_SECOND
          A constant for the last millisecond in a second.
 
Fields inherited from class com.jrefinery.data.TimePeriod
DEFAULT_TIME_ZONE, WORKING_CALENDAR
 
Fields inherited from interface com.jrefinery.date.MonthConstants
APRIL, AUGUST, DECEMBER, FEBRUARY, JANUARY, JULY, JUNE, MARCH, MAY, NOVEMBER, OCTOBER, SEPTEMBER
 
Constructor Summary
Millisecond()
          Constructs a millisecond based on the current system time.
Millisecond(java.util.Date time)
          Constructs a millisecond.
Millisecond(java.util.Date time, java.util.TimeZone zone)
          Creates a millisecond.
Millisecond(int millisecond, Second second)
          Constructs a millisecond.
 
Method Summary
 int compareTo(java.lang.Object o1)
          Returns an integer indicating the order of this Millisecond object relative to the specified object: negative == before, zero == same, positive == after.
 boolean equals(java.lang.Object object)
          Tests the equality of this object against an arbitrary Object.
 long getEnd()
          Returns the last millisecond of the time period.
 long getEnd(java.util.Calendar calendar)
          Returns the last millisecond of the time period.
 long getMillisecond()
          Returns the millisecond.
 Second getSecond()
          Returns the second.
 long getSerialIndex()
          Returns a serial index number for the millisecond.
 long getStart()
          Returns the first millisecond of the time period.
 long getStart(java.util.Calendar calendar)
          Returns the first millisecond of the time period.
 TimePeriod next()
          Returns the millisecond following this one.
 TimePeriod previous()
          Returns the millisecond preceding this one.
 java.lang.String toString()
          Returns a string representation of the millisecond.
 
Methods inherited from class com.jrefinery.data.TimePeriod
getEnd, getMiddle, getMiddle, getMiddle, getStart
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST_MILLISECOND_IN_SECOND

public static final int FIRST_MILLISECOND_IN_SECOND
A constant for the first millisecond in a second.

LAST_MILLISECOND_IN_SECOND

public static final int LAST_MILLISECOND_IN_SECOND
A constant for the last millisecond in a second.
Constructor Detail

Millisecond

public Millisecond()
Constructs a millisecond based on the current system time.

Millisecond

public Millisecond(int millisecond,
                   Second second)
Constructs a millisecond.
Parameters:
millisecond - the millisecond (0-999).
second - the second.

Millisecond

public Millisecond(java.util.Date time)
Constructs a millisecond.
Parameters:
time - the time.

Millisecond

public Millisecond(java.util.Date time,
                   java.util.TimeZone zone)
Creates a millisecond.
Parameters:
time - the instant in time.
zone - the time zone.
Method Detail

getSecond

public Second getSecond()
Returns the second.
Returns:
The second.

getMillisecond

public long getMillisecond()
Returns the millisecond.
Returns:
the millisecond.

previous

public TimePeriod previous()
Returns the millisecond preceding this one.
Overrides:
previous in class TimePeriod
Returns:
the millisecond preceding this one.

next

public TimePeriod next()
Returns the millisecond following this one.
Overrides:
next in class TimePeriod
Returns:
the millisecond following this one.

getSerialIndex

public long getSerialIndex()
Returns a serial index number for the millisecond.
Overrides:
getSerialIndex in class TimePeriod
Returns:
The serial index number.

equals

public boolean equals(java.lang.Object object)
Tests the equality of this object against an arbitrary Object.

This method will return true ONLY if the object is a Millisecond object representing the same millisecond as this instance.

Overrides:
equals in class java.lang.Object
Parameters:
object - the object to compare
Returns:
true if milliseconds and seconds of this and object are the same.

compareTo

public int compareTo(java.lang.Object o1)
Returns an integer indicating the order of this Millisecond 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.

getStart

public long getStart()
Returns the first millisecond of the time period.
Overrides:
getStart in class TimePeriod
Returns:
the first millisecond of the time period.

getStart

public long getStart(java.util.Calendar calendar)
Returns the first millisecond of the time period.
Overrides:
getStart in class TimePeriod
Parameters:
calendar - the calendar.
Returns:
The first millisecond of the time period.

getEnd

public long getEnd()
Returns the last millisecond of the time period.
Overrides:
getEnd in class TimePeriod
Returns:
the last millisecond of the time period.

getEnd

public long getEnd(java.util.Calendar calendar)
Returns the last millisecond of the time period.
Overrides:
getEnd in class TimePeriod
Parameters:
calendar - the calendar.
Returns:
The last millisecond of the time period.

toString

public java.lang.String toString()
Returns a string representation of the millisecond.
Overrides:
toString in class java.lang.Object
Returns:
the string.