Package eu.webtoolkit.jwt
Class WTime
java.lang.Object
eu.webtoolkit.jwt.WTime
public class WTime
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description WTime(int hours, int minutes)
Construct a time given hour, minutes.WTime(int h, int m, int s)
Construct a time given hour, minutes, seconds.WTime(int h, int m, int s, int ms)
Construct a time given hour, minutes, seconds, and milliseconds.WTime(long ms)
Create time from a number of milliseconds since the EPOCH. -
Method Summary
Modifier and Type Method Description WTime
addSecs(int seconds)
boolean
after(WTime t)
Compares current time to given timeboolean
before(WTime t)
Compares current time to given timeboolean
beforeOrEquals(WTime t)
Compares current time to given timeboolean
equals(WTime t)
Compares current time to given timestatic eu.webtoolkit.jwt.WTime.RegExpInfo
formatToRegExp(java.lang.String format)
Converts the format to a regular expression The Format can contains characters with special meaning (@see #toString(String)) Any other text is kept literally.static WTime
fromString(java.lang.String text)
Parses a string to a time using a default format.static WTime
fromString(java.lang.String text, java.lang.String format)
Parses a string to a time using a specified format.static WTime
getCurrentServerTime()
Reports the current local server time.static WTime
getCurrentTime()
Reports the current local client time.static java.lang.String
getDefaultFormat()
Returns the default format of the time HH:mm:ssint
getHour()
Returns the hourint
getMinute()
Returns the minutesint
getMsec()
Returns the millisecondsint
getPmHour()
Returns the hour in AM/PM formatint
getSecond()
Returns the secondsboolean
isValid()
Returns true if time is valid timelong
msecsTo(WTime t)
Returns the number of milliseconds until tlong
secsTo(WTime t)
Returns the number of seconds until tboolean
setHMS(int h, int m, int s, int ms)
Sets the time.java.lang.String
toString()
Returns the string format of the time using the default formatjava.lang.String
toString(java.lang.String format)
Formats this time to a string using a specified format.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
WTime
public WTime(int hours, int minutes)Construct a time given hour, minutes.- Parameters:
minutes
- a range 0-59 A duration can be positive or negative depending on the sign of @param hours. When the time is invalid, isValid() is set to false.
-
WTime
public WTime(int h, int m, int s)Construct a time given hour, minutes, seconds. minutes and seconds have range 0-59 A duration can be positive or negative depending on the sign of hour. When the time is invalid, isValid() is set to false. -
WTime
public WTime(int h, int m, int s, int ms)Construct a time given hour, minutes, seconds, and milliseconds. m and s have range 0-59, and ms has range 0-999. A duration can be positive or negative depending on the sign of h. When the time is invalid, isValid() is set to false. -
WTime
public WTime(long ms)Create time from a number of milliseconds since the EPOCH.- Parameters:
ms
-
-
-
Method Details
-
setHMS
public boolean setHMS(int h, int m, int s, int ms)Sets the time. m and s have range 0-59, and ms has range 0-999. When the time is invalid, isValid() is set to false. -
getHour
public int getHour()Returns the hour -
getPmHour
public int getPmHour()Returns the hour in AM/PM format -
getMinute
public int getMinute()Returns the minutes -
getSecond
public int getSecond()Returns the seconds -
getMsec
public int getMsec()Returns the milliseconds -
secsTo
Returns the number of seconds until t -
msecsTo
Returns the number of milliseconds until t -
addSecs
-
getDefaultFormat
public static java.lang.String getDefaultFormat()Returns the default format of the time HH:mm:ss -
fromString
Parses a string to a time using a default format. The default format is "HH:mm:ss". For example, a time specified as: "22:55:15" will be parsed as a time that equals a time constructed as: WTime d(22,55,15); When the time could not be parsed or is not valid, an invalid time is returned (for which isValid() returns false). -
fromString
Parses a string to a time using a specified format. The format follows the same syntax as used by toString(String format). When the time could not be parsed or is not valid, an invalid time is returned (for which isValid() returns false).- See Also:
toString()
-
toString
public java.lang.String toString(java.lang.String format)Formats this time to a string using a specified format.- See Also:
SimpleDateFormat
-
getCurrentServerTime
Reports the current local server time. This method returns the time as indicated by the server clock. -
getCurrentTime
Reports the current local client time. This method uses browser information to retrieve the date that is configured in the client. -
toString
public java.lang.String toString()Returns the string format of the time using the default format- Overrides:
toString
in classjava.lang.Object
-
isValid
public boolean isValid()Returns true if time is valid time -
formatToRegExp
public static eu.webtoolkit.jwt.WTime.RegExpInfo formatToRegExp(java.lang.String format)Converts the format to a regular expression The Format can contains characters with special meaning (@see #toString(String)) Any other text is kept literally. String content between single quotes (') are not interpreted as special codes. Inside a string, a literal quote may be specified using two single quotes (''). -
before
Compares current time to given time- Returns:
- true when current time is earlier than given time
-
after
Compares current time to given time- Returns:
- true when current time is later than given time
-
equals
Compares current time to given time- Returns:
- true when times are equal
-
beforeOrEquals
Compares current time to given time- Returns:
- true when current time is earlier than or equal to given time
-