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 - 2025
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    milliseconds in an hour.
    private int
    The hour.
    private boolean
    Is the time negative
    private int
    The milliseconds.
    private static final int
    milliseconds in a minute.
    private int
    The minutes.
    private static final int
    milliseconds in a second.
    private int
    The seconds.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    int
    Get the hour.
    int
    Get the milliseconds.
    int
    Get the minutes.
    int
    Get the seconds.
    double
    Returns the time in milliseconds by converting hours, minutes and seconds into milliseconds.
    boolean
    Does the time represent a negative time, such as using this to subtract time from another Time.
    void
    setHours(int hours)
    Set the hour.
    void
    setIsNegative(boolean isNegative)
    Set this to represent a negative time.
    void
    setMilliseconds(int milliseconds)
    Set the milliseconds.
    void
    setMinutes(int minutes)
    Set the minutes.
    void
    setSeconds(int seconds)
    Set the 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 milliseconds.
      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 from 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, such 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()
      Get the hour.
      Returns:
      Returns the hour.
    • setHours

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

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

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

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

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

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

      public void setMilliseconds(int milliseconds)
      Set the 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: