Class Time

java.lang.Object
com.twelvemonkeys.util.Time

public class Time extends Object
Utility class for storing times in a simple way. The internal time is stored as an int, counting seconds.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new time with 0 seconds, 0 minutes.
    Time(int pTime)
    Creates a new time with the given time (in seconds).
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the minutes part of the time.
    int
    Gets the seconds part of the time.
    int
    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 seconds
    Creates a string representation of the time object.
    toString(String pFormatStr)
    Deprecated. 

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • time

      private int time
    • 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

      public String 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.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the time object
      See Also:
    • toString

      @Deprecated public String toString(String pFormatStr)
      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 public static Time parseTime(String pStr)
      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: