Class WTime

java.lang.Object
eu.webtoolkit.jwt.WTime

public class WTime extends 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
    addSecs(int seconds)
     
    boolean
    Compares current time to given time
    boolean
    Compares current time to given time
    boolean
    Compares current time to given time
    boolean
    Compares current time to given time
    static eu.webtoolkit.jwt.WTime.RegExpInfo
    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
    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:ss
    int
    Returns the hour
    int
    Returns the minutes
    int
    Returns the milliseconds
    int
    Returns the hour in AM/PM format
    int
    Returns the seconds
    boolean
    Returns true if time is valid time
    long
    Returns the number of milliseconds until t
    long
    Returns the number of seconds until t
    boolean
    setHMS(int h, int m, int s, int ms)
    Sets the time.
    Returns the string format of the time using the default format
    toString(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

      public long secsTo(WTime t)
      Returns the number of seconds until t
    • msecsTo

      public long msecsTo(WTime t)
      Returns the number of milliseconds until t
    • addSecs

      public WTime addSecs(int seconds)
    • getDefaultFormat

      public static String getDefaultFormat()
      Returns the default format of the time HH:mm:ss
    • fromString

      public static WTime fromString(String text)
      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

      public static WTime fromString(String text, String format)
      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

      public String toString(String format)
      Formats this time to a string using a specified format.
      See Also:
    • getCurrentServerTime

      public static WTime getCurrentServerTime()
      Reports the current local server time. This method returns the time as indicated by the server clock.
    • getCurrentTime

      public static WTime getCurrentTime()
      Reports the current local client time. This method uses browser information to retrieve the date that is configured in the client.
    • toString

      public String toString()
      Returns the string format of the time using the default format
      Overrides:
      toString in class Object
    • isValid

      public boolean isValid()
      Returns true if time is valid time
    • formatToRegExp

      public static 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. 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

      public boolean before(WTime t)
      Compares current time to given time
      Returns:
      true when current time is earlier than given time
    • after

      public boolean after(WTime t)
      Compares current time to given time
      Returns:
      true when current time is later than given time
    • equals

      public boolean equals(WTime t)
      Compares current time to given time
      Returns:
      true when times are equal
    • beforeOrEquals

      public boolean beforeOrEquals(WTime t)
      Compares current time to given time
      Returns:
      true when current time is earlier than or equal to given time