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) booleanCompares current time to given timebooleanCompares current time to given timebooleanCompares current time to given timebooleanCompares current time to given timestatic eu.webtoolkit.jwt.WTime.RegExpInfoformatToRegExp(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 WTimefromString(String text) Parses a string to a time using a default format.static WTimefromString(String text, String format) Parses a string to a time using a specified format.static WTimeReports the current local server time.static WTimeReports the current local client time.static StringReturns the default format of the time HH:mm:ssintgetHour()Returns the hourintReturns the minutesintgetMsec()Returns the millisecondsintReturns the hour in AM/PM formatintReturns the secondsbooleanisValid()Returns true if time is valid timelongReturns the number of milliseconds until tlongReturns the number of seconds until tbooleansetHMS(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
-