Package com.twelvemonkeys.util
Class Time
java.lang.Object
com.twelvemonkeys.util.Time
Utility class for storing times in a simple way. The internal time is stored
as an int, counting seconds.
- Author:
- Harald Kuhr
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the minutes part of the time.int
Gets the seconds part of the time.int
getTime()
Gets the full time in seconds.long
Gets the full time in milliseconds, for use in creating dates or similar.static Time
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 secondstoString()
Creates a string representation of the time object.Deprecated.
-
Field Details
-
SECONDS_IN_MINUTE
public static final int SECONDS_IN_MINUTE- See Also:
-
-
Constructor Details
-
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 Details
-
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:
-
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
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. -
toString
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:
-
parseTime
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:
-