Class Time

java.lang.Object
com.kosherjava.zmanim.util.Time

public class Time extends Object
A class that represents a numeric time. Times that represent a time of day are stored as Dates in this API. The time class is used to represent numeric time such as the time in hours, minutes, seconds and milliseconds of a temporal hour.
Author:
© Eliyahu Hershfeld 2004 - 2020
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    milliseconds in an hour.
    private int
     
    private boolean
     
    private int
     
    private static final int
    milliseconds in a minute.
    private int
     
    private static final int
    milliseconds in a second.
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Time(double millis)
    Constructor with a parameter for milliseconds.
    Time(int millis)
    A constructor that sets the time by milliseconds.
    Time(int hours, int minutes, int seconds, int milliseconds)
    Constructor with parameters for the hours, minutes, seconds and millisecods.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
    int
     
    int
     
    double
    Returns the time in milliseconds by converting hours, minutes and seconds into milliseconds.
    boolean
    Does the time represent a negative time 9such as using this to subtract time from another Time.
    void
    setHours(int hours)
     
    void
    setIsNegative(boolean isNegative)
    Set this to represent a negative time.
    void
    setMilliseconds(int milliseconds)
     
    void
    setMinutes(int minutes)
     
    void
    setSeconds(int seconds)
     
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • Time

      public Time(int hours, int minutes, int seconds, int milliseconds)
      Constructor with parameters for the hours, minutes, seconds and millisecods.
      Parameters:
      hours - the hours to set
      minutes - the minutes to set
      seconds - the seconds to set
      milliseconds - the milliseconds to set
    • Time

      public Time(double millis)
      Constructor with a parameter for milliseconds. This constructor casts the milliseconds to an int and calls Time(int)
      Parameters:
      millis - the milliseconds to set the object with.
    • Time

      public Time(int millis)
      A constructor that sets the time by milliseconds. The milliseconds are converted to hours, minutes, seconds and milliseconds. If the milliseconds are negative it will call setIsNegative(boolean).
      Parameters:
      millis - the milliseconds to set.
  • Method Details

    • isNegative

      public boolean isNegative()
      Does the time represent a negative time 9such as using this to subtract time from another Time.
      Returns:
      if the time is negative.
    • setIsNegative

      public void setIsNegative(boolean isNegative)
      Set this to represent a negative time.
      Parameters:
      isNegative - that the Time represents negative time
    • getHours

      public int getHours()
      Returns:
      Returns the hour.
    • setHours

      public void setHours(int hours)
      Parameters:
      hours - The hours to set.
    • getMinutes

      public int getMinutes()
      Returns:
      Returns the minutes.
    • setMinutes

      public void setMinutes(int minutes)
      Parameters:
      minutes - The minutes to set.
    • getSeconds

      public int getSeconds()
      Returns:
      Returns the seconds.
    • setSeconds

      public void setSeconds(int seconds)
      Parameters:
      seconds - The seconds to set.
    • getMilliseconds

      public int getMilliseconds()
      Returns:
      Returns the milliseconds.
    • setMilliseconds

      public void setMilliseconds(int milliseconds)
      Parameters:
      milliseconds - The milliseconds to set.
    • getTime

      public double getTime()
      Returns the time in milliseconds by converting hours, minutes and seconds into milliseconds.
      Returns:
      the time in milliseconds
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also: