Package eu.webtoolkit.jwt
Class WTime
java.lang.Object
eu.webtoolkit.jwt.WTime
-
Constructor Summary
ConstructorsConstructorDescriptionWTime
(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 TypeMethodDescriptionaddSecs
(int seconds) boolean
Compares current time to given timeboolean
Compares current time to given timeboolean
Compares current time to given timeboolean
Compares current time to given timestatic eu.webtoolkit.jwt.WTime.RegExpInfo
formatToRegExp
(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
(String text) Parses a string to a time using a default format.static WTime
fromString
(String text, String format) Parses a string to a time using a specified format.static WTime
Reports the current local server time.static WTime
Reports the current local client time.static String
Returns the default format of the time HH:mm:ssint
getHour()
Returns the hourint
Returns the minutesint
getMsec()
Returns the millisecondsint
Returns the hour in AM/PM formatint
Returns the secondsboolean
isValid()
Returns true if time is valid timelong
Returns the number of milliseconds until tlong
Returns the number of seconds until tboolean
setHMS
(int h, int m, int s, int ms) Sets the time.toString()
Returns the string format of the time using the default formatFormats this time to a string using a specified format.
-
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
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
Formats this time to a string using a specified format.- See Also:
-
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
Returns the string format of the time using the default format -
isValid
public boolean isValid()Returns true if time is valid time -
formatToRegExp
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
-