com.twelvemonkeys.util
Class Time

java.lang.Object
  extended by com.twelvemonkeys.util.Time

public class Time
extends Object

Utility class for storing times in a simple way. The internal time is stored as an int, counting seconds.

Author:
Harald Kuhr

Field Summary
static int SECONDS_IN_MINUTE
           
 
Constructor Summary
Time()
          Creates a new time with 0 seconds, 0 minutes.
Time(int pTime)
          Creates a new time with the given time (in seconds).
 
Method Summary
 int getMinutes()
          Gets the minutes part of the time.
 int getSeconds()
          Gets the seconds part of the time.
 int getTime()
          Gets the full time in seconds.
 long getTimeInMillis()
          Gets the full time in milliseconds, for use in creating dates or similar.
static Time parseTime(String pStr)
          Deprecated.  
 void setMinutes(int pMinutes)
          Sets the minutes part of the time.
 void setSeconds(int pSeconds)
          Sets the seconds part of the time.
 void setTime(int pTime)
          Sets the full time in seconds
 String toString()
          Creates a string representation of the time object.
 String toString(String pFormatStr)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SECONDS_IN_MINUTE

public static final int SECONDS_IN_MINUTE
See Also:
Constant Field Values
Constructor Detail

Time

public Time()
Creates a new time with 0 seconds, 0 minutes.


Time

public Time(int pTime)
Creates a new time with the given time (in seconds).

Method Detail

setTime

public void setTime(int pTime)
Sets the full time in seconds


getTime

public int getTime()
Gets the full time in seconds.


getTimeInMillis

public long getTimeInMillis()
Gets the full time in milliseconds, for use in creating dates or similar.

See Also:
Date.setTime(long)

setSeconds

public void setSeconds(int pSeconds)
Sets the seconds part of the time. Note, if the seconds argument is 60 or greater, the value will "wrap", and increase the minutes also.

Parameters:
pSeconds - an integer that should be between 0 and 59.

getSeconds

public int getSeconds()
Gets the seconds part of the time.

Returns:
an integer between 0 and 59

setMinutes

public void setMinutes(int pMinutes)
Sets the minutes part of the time.

Parameters:
pMinutes - an integer

getMinutes

public int getMinutes()
Gets the minutes part of the time.

Returns:
an integer

toString

public String toString()
Creates a string representation of the time object. The string is returned on the form m:ss, where m is variable digits minutes and ss is two digits seconds.

Overrides:
toString in class Object
Returns:
a string representation of the time object
See Also:
toString(String)

toString

public String toString(String pFormatStr)
Deprecated. 

Creates a string representation of the time object. The string returned is on the format of the formatstring.
m (or any multiple of m's)
the minutes part (padded with 0's, if number has less digits than the number of m's) m -> 0,1,...,59,60,61,... mm -> 00,01,...,59,60,61,...
s or ss
the seconds part (padded with 0's, if number has less digits than the number of s's) s -> 0,1,...,59 ss -> 00,01,...,59
S
all seconds (including the ones above 59)

Parameters:
pFormatStr - the format where
Returns:
a string representation of the time object
Throws:
NumberFormatException
See Also:
TimeFormat.format(Time), parseTime(String)

parseTime

public static Time parseTime(String pStr)
Deprecated. 

Creates a string representation of the time object. The string is returned on the form m:ss, where m is variable digits minutes and ss is two digits seconds.

Returns:
a string representation of the time object
Throws:
NumberFormatException
See Also:
TimeFormat.parse(String), toString(String)


Copyright © 2015. All Rights Reserved.