org.sakaiproject.component.legacy.time
Class MyTime

java.lang.Object
  extended byorg.sakaiproject.component.legacy.time.MyTime
All Implemented Interfaces:
Cloneable, Comparable, Serializable, Time

public class MyTime
extends Object
implements Time

MyTime is an implementation of the Time API Time.

Author:
Sakai Software Development Team
See Also:
Serialized Form

Field Summary
protected  long m_millisecondsSince
          The milliseconds since... same as Date
 
Constructor Summary
MyTime()
          construct as now
MyTime(long l)
          construct from a Long
MyTime(String str)
          construct from a string, in our format, GMT values
MyTime(TimeZone zone, int year, int month, int day, int hour, int minute, int second, int millisecond)
          construct from individual ints, and the zone.
MyTime(TimeZone zone, TimeBreakdown tb)
          construct from time breakdown, and the zone.
 
Method Summary
 boolean after(Time other)
          Is this time after the other time?
 boolean before(Time other)
          Is this time before the other time?
 TimeBreakdown breakdownGmt()
          Access the time value as a TimeBreakdown object, in GMT
 TimeBreakdown breakdownLocal()
          Access the time value as a TimeBreakdown object, in Local
 Object clone()
          
 int compareTo(Object o)
          
 boolean equals(Object obj)
          
protected  String fix(String s)
          Fix the AM/PM format of the time string - lower the case.
 long getTime()
          Access the milliseconds since.
 void setTime(long l)
          Set the time in milliseconds since.
 String toString()
          
 String toStringFilePath()
          Format as a file path based on the date and time.
 String toStringGmtDate()
          Format as a string, Human Readable, date only format, GMT.
 String toStringGmtFull()
          Format as a string, Human Readable, full format, GMT.
 String toStringGmtShort()
          Format as a string, Human Readable, short (time only) format, GMT.
 String toStringGmtTime()
          Format as a string, Human Readable, time only format, GMT.
 String toStringLocal()
          Format as a string, Local time zone.
 String toStringLocalDate()
          Format as a string, Human Readable, date only format, Local.
 String toStringLocalFull()
          Format as a string, Human Readable, full format, Local.
 String toStringLocalFullZ()
          Format as a string, Human Readable, full format, Local, with zone.
 String toStringLocalShort()
          Format as a string, Human Readable, short (time only) format, Local.
 String toStringLocalShortDate()
          Format as a string, short format: MM/DD/YY, Local.
 String toStringLocalTime()
          Format as a string, Human Readable, time only format, Local.
 String toStringLocalTime24()
          Format as a string, Human Readable, time only format, 24hour Local.
 String toStringLocalTimeZ()
          Format as a string, Human Readable, time only format, Local, with zone.
 String toStringSql()
          Format as a string, GMT, for a SQL statement.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_millisecondsSince

protected long m_millisecondsSince
The milliseconds since... same as Date

Constructor Detail

MyTime

public MyTime(String str)
construct from a string, in our format, GMT values

Parameters:
str - time format string

MyTime

public MyTime()
construct as now


MyTime

public MyTime(long l)
construct from a Long

Parameters:
l - time value in ms since...

MyTime

public MyTime(TimeZone zone,
              int year,
              int month,
              int day,
              int hour,
              int minute,
              int second,
              int millisecond)
construct from individual ints, and the zone.

Parameters:
zone - The time zone.
year - full year (i.e. 1999, 2000)
month - month in year (1..12)
day - day in month (1..31)
hour - hour in day (0..23)
second - second in minute (0..59)
millisecond - millisecond in second (0..999)

MyTime

public MyTime(TimeZone zone,
              TimeBreakdown tb)
construct from time breakdown, and the zone.

Parameters:
zone - The time zone.
tb - The TimeBreakdown with the values.
Method Detail

clone

public Object clone()

Specified by:
clone in interface Time

toString

public String toString()


toStringSql

public String toStringSql()
Format as a string, GMT, for a SQL statement.

Specified by:
toStringSql in interface Time
Returns:
Time in string format.

toStringLocal

public String toStringLocal()
Format as a string, Local time zone.

Specified by:
toStringLocal in interface Time
Returns:
Time in string format.

toStringGmtFull

public String toStringGmtFull()
Format as a string, Human Readable, full format, GMT.

Specified by:
toStringGmtFull in interface Time
Returns:
Time in string format.

toStringLocalFull

public String toStringLocalFull()
Format as a string, Human Readable, full format, Local.

Specified by:
toStringLocalFull in interface Time
Returns:
Time in string format.

toStringLocalFullZ

public String toStringLocalFullZ()
Format as a string, Human Readable, full format, Local, with zone.

Specified by:
toStringLocalFullZ in interface Time
Returns:
Time in string format.

toStringGmtShort

public String toStringGmtShort()
Format as a string, Human Readable, short (time only) format, GMT.

Specified by:
toStringGmtShort in interface Time
Returns:
Time in string format.

toStringLocalShort

public String toStringLocalShort()
Format as a string, Human Readable, short (time only) format, Local.

Specified by:
toStringLocalShort in interface Time
Returns:
Time in string format.

toStringGmtTime

public String toStringGmtTime()
Format as a string, Human Readable, time only format, GMT.

Specified by:
toStringGmtTime in interface Time
Returns:
Time in string format.

toStringLocalTime

public String toStringLocalTime()
Format as a string, Human Readable, time only format, Local.

Specified by:
toStringLocalTime in interface Time
Returns:
Time in string format.

toStringLocalTimeZ

public String toStringLocalTimeZ()
Format as a string, Human Readable, time only format, Local, with zone.

Specified by:
toStringLocalTimeZ in interface Time
Returns:
Time in string format.

toStringLocalTime24

public String toStringLocalTime24()
Format as a string, Human Readable, time only format, 24hour Local.

Specified by:
toStringLocalTime24 in interface Time
Returns:
Time in string format.

toStringGmtDate

public String toStringGmtDate()
Format as a string, Human Readable, date only format, GMT.

Specified by:
toStringGmtDate in interface Time
Returns:
Time in string format.

toStringLocalDate

public String toStringLocalDate()
Format as a string, Human Readable, date only format, Local.

Specified by:
toStringLocalDate in interface Time
Returns:
Time in string format.

toStringLocalShortDate

public String toStringLocalShortDate()
Format as a string, short format: MM/DD/YY, Local.

Specified by:
toStringLocalShortDate in interface Time
Returns:
Time in string format.

toStringFilePath

public String toStringFilePath()
Format as a file path based on the date and time.

Specified by:
toStringFilePath in interface Time
Returns:
Time is string format.

equals

public boolean equals(Object obj)


compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable

setTime

public void setTime(long l)
Set the time in milliseconds since.

Specified by:
setTime in interface Time
Parameters:
l - The milliseconds since value for the time.

getTime

public long getTime()
Access the milliseconds since.

Specified by:
getTime in interface Time
Returns:
The milliseconds since value.

before

public boolean before(Time other)
Is this time before the other time?

Specified by:
before in interface Time
Parameters:
other - The other time for the comparison.
Returns:
true if this time is before the other, false if not.

after

public boolean after(Time other)
Is this time after the other time?

Specified by:
after in interface Time
Parameters:
other - The other time for the comparison.
Returns:
true if this time is after the other, false if not.

fix

protected String fix(String s)
Fix the AM/PM format of the time string - lower the case.

Parameters:
s - The time string.
Returns:
The time string fixed.

breakdownGmt

public TimeBreakdown breakdownGmt()
Access the time value as a TimeBreakdown object, in GMT

Specified by:
breakdownGmt in interface Time
Returns:
A TimeBreakdown object representing this time's value in GMT

breakdownLocal

public TimeBreakdown breakdownLocal()
Access the time value as a TimeBreakdown object, in Local

Specified by:
breakdownLocal in interface Time
Returns:
A TimeBreakdown object representing this time's value in GMT