net.sourceforge.jpalm.mobiledb.field.type
Class Time

java.lang.Object
  extended by net.sourceforge.jpalm.mobiledb.field.type.Time
All Implemented Interfaces:
java.lang.Comparable<Time>, Type<Time>

public class Time
extends java.lang.Object
implements Type<Time>, java.lang.Comparable<Time>

A time field in a MobileDB record.


Field Summary
static int MAX_SECONDS
          The maximum number of seconds.
86399
static int MIN_SECONDS
          The minimum number of seconds.
0
 
Constructor Summary
Time()
          Creates a new time representing the current time.
Time(int seconds)
          Creates a new time from seconds.
 
Method Summary
 int compareTo(Time time)
          Compares this time to to another time based on the number of seconds since 00:00.
 boolean equals(java.lang.Object object)
           
static Time fromMobileDB(java.lang.String string)
          Creates a time from the MobileDB value.
 int getSeconds()
          Gets this time as the number of seconds since 00:00.
 Time getValue()
          Gets the native object for this type.
 java.lang.String toMobileDB()
          Gets the MobileDB value for this type.
 java.lang.String toString()
          Gets a string representation of this time in HH:mm format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_SECONDS

public static final int MAX_SECONDS
The maximum number of seconds.
86399

See Also:
Constant Field Values

MIN_SECONDS

public static final int MIN_SECONDS
The minimum number of seconds.
0

See Also:
Constant Field Values
Constructor Detail

Time

public Time()
Creates a new time representing the current time.


Time

public Time(int seconds)
Creates a new time from seconds. If seconds is not between 0 and 86399 (inclusive) then seconds defaults to 0.

Parameters:
seconds - the number of seconds since 00:00.
Method Detail

getSeconds

public int getSeconds()
Gets this time as the number of seconds since 00:00.

Returns:
the number of seconds since 00:00

toString

public java.lang.String toString()
Gets a string representation of this time in HH:mm format.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this time

equals

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

compareTo

public int compareTo(Time time)
Compares this time to to another time based on the number of seconds since 00:00.

Specified by:
compareTo in interface java.lang.Comparable<Time>
Parameters:
time - a time to compare to
Returns:
less than 0 if time is less than this time, 0 if time is equal to this time, or greater than 0 if time is greater than this time

toMobileDB

public java.lang.String toMobileDB()
Description copied from interface: Type
Gets the MobileDB value for this type.

Specified by:
toMobileDB in interface Type<Time>
Returns:
the MobileDB value

fromMobileDB

public static Time fromMobileDB(java.lang.String string)
Creates a time from the MobileDB value.

Parameters:
string - the MobileDB value to convert
Returns:
a time

getValue

public Time getValue()
Description copied from interface: Type
Gets the native object for this type.

Specified by:
getValue in interface Type<Time>
Returns:
the native object