cdx.scorebot.util
Class Timestamp

java.lang.Object
  extended by cdx.scorebot.util.Timestamp
All Implemented Interfaces:
java.io.Serializable

public class Timestamp
extends java.lang.Object
implements java.io.Serializable

provides easy access to UTC ms from the epoch

Author:
David Underhill
See Also:
Serialized Form

Constructor Summary
Timestamp()
          sets the timestamp to the current time
Timestamp(java.util.GregorianCalendar c)
          sets the timestamp to the specified time
Timestamp(long m)
          sets the timestamp to the specified time
 
Method Summary
 int compareTo(Timestamp t)
          Compares this Timestamp with the specified Timestamp: earliest timestamp will come first.
 boolean equals(java.lang.Object o)
           
static long getCurrentTime()
          gets current number of ms since the epoch
 long getMyTime()
          gets the number of milliseconds since the epoch for this timestamp
 long getTime(java.util.GregorianCalendar c)
          gets the number of milliseconds from the epoch to the specified date/time c
 java.lang.String toFNSafeString()
          returns the date/time of this timestamp as yyyy-MM-dd_HH-mm-ss
 java.lang.String toString()
          returns the date/time of this timestamp as dd-MMM-yyyy HH:mm:ss
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timestamp

public Timestamp()
sets the timestamp to the current time


Timestamp

public Timestamp(java.util.GregorianCalendar c)
sets the timestamp to the specified time

Parameters:
c - date/time to set this timestamp equal to

Timestamp

public Timestamp(long m)
sets the timestamp to the specified time

Parameters:
m - the number of milliseconds since the epoch
Method Detail

compareTo

public int compareTo(Timestamp t)
Compares this Timestamp with the specified Timestamp: earliest timestamp will come first.

Parameters:
t - the Timestamp to compare this to
Returns:
-1, 0, 1 as this Timestamp is less than, equal to, or greater than the specified Timestamp.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getTime

public long getTime(java.util.GregorianCalendar c)
gets the number of milliseconds from the epoch to the specified date/time c

Parameters:
c - date/time to set this timestamp equal to
Returns:
number of milliseconds since

getCurrentTime

public static long getCurrentTime()
gets current number of ms since the epoch

Returns:
number of ms since the epoch

toFNSafeString

public java.lang.String toFNSafeString()
returns the date/time of this timestamp as yyyy-MM-dd_HH-mm-ss


toString

public java.lang.String toString()
returns the date/time of this timestamp as dd-MMM-yyyy HH:mm:ss

Overrides:
toString in class java.lang.Object

getMyTime

public long getMyTime()
gets the number of milliseconds since the epoch for this timestamp