Package com.twelvemonkeys.util
Class Time
- java.lang.Object
-
- com.twelvemonkeys.util.Time
-
public class Time extends java.lang.Object
Utility class for storing times in a simple way. The internal time is stored as an int, counting seconds.
-
-
Field Summary
Fields Modifier and Type Field Description static int
SECONDS_IN_MINUTE
private int
time
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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(java.lang.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 secondsjava.lang.String
toString()
Creates a string representation of the time object.java.lang.String
toString(java.lang.String pFormatStr)
Deprecated.
-
-
-
Field Detail
-
time
private int time
-
SECONDS_IN_MINUTE
public static final int SECONDS_IN_MINUTE
- See Also:
- Constant Field Values
-
-
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 java.lang.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 classjava.lang.Object
- Returns:
- a string representation of the time object
- See Also:
toString(String)
-
toString
@Deprecated public java.lang.String toString(java.lang.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:
java.lang.NumberFormatException
- See Also:
TimeFormat.format(Time)
,parseTime(String)
-
parseTime
@Deprecated public static Time parseTime(java.lang.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:
java.lang.NumberFormatException
- See Also:
TimeFormat.parse(String)
,toString(String)
-
-