Class TimeOfDay


  • public final class TimeOfDay
    extends Object
    A specific moment of time on a 24-hour clock. A TimeOfDay contains only time information, up to millisecond precision.

    A TimeOfDay only partially specifies an instant in the time continuum; it must be combined with a CalendarDate and TimeZone to produce a specific instant.

    See Also:
    Time
    • Constructor Summary

      Constructors 
      Constructor Description
      TimeOfDay()
      Constructs an instance representing the current time in the default timezone.
      TimeOfDay​(int dayMillis)
      Constructs an instance representing the time occurring the specified number of milliseconds after midnight.
      TimeOfDay​(int hourOfDay, int minuteOfHour)
      Constructs an instance representing the specified time, expressed in 24-hour format.
      TimeOfDay​(int hourOfDay, int minuteOfHour, int secondOfMinute)
      Constructs an instance representing the specified time, expressed using 24-hour format.
      TimeOfDay​(Date time, TimeZone tz)
      Constructs an instance representing the specified time in the given time zone.
      TimeOfDay​(TimeZone tz)
      Constructs an instance representing the current time in the specified timezone.
    • Constructor Detail

      • TimeOfDay

        public TimeOfDay()
        Constructs an instance representing the current time in the default timezone.
      • TimeOfDay

        public TimeOfDay​(TimeZone tz)
        Constructs an instance representing the current time in the specified timezone.
        Parameters:
        tz - the timezone to which the current time is relative
      • TimeOfDay

        public TimeOfDay​(int dayMillis)
        Constructs an instance representing the time occurring the specified number of milliseconds after midnight.
        Parameters:
        dayMillis - the number of milliseconds elapsed since midnight
      • TimeOfDay

        public TimeOfDay​(int hourOfDay,
                         int minuteOfHour)
        Constructs an instance representing the specified time, expressed in 24-hour format.
        Parameters:
        hourOfDay - the hour portion of the time
        minuteOfHour - the minute portion of the time
      • TimeOfDay

        public TimeOfDay​(int hourOfDay,
                         int minuteOfHour,
                         int secondOfMinute)
        Constructs an instance representing the specified time, expressed using 24-hour format.
        Parameters:
        hourOfDay - the hour portion of the time
        minuteOfHour - the minutes portion of the time
        secondOfMinute - the seconds portion of the time
      • TimeOfDay

        public TimeOfDay​(Date time,
                         TimeZone tz)
        Constructs an instance representing the specified time in the given time zone.
        Parameters:
        time - the instant in time from which to extract time information
        tz - the time zone in which to interpret the specified instant
    • Method Detail

      • getMillisSinceMidnight

        public int getMillisSinceMidnight()
        Get the number of milliseconds elapsed since midnight
        Returns:
        milliseconds elapsed since midnight
      • getHourOfDay

        public int getHourOfDay()
        Get the hour portion, in 24-hour format, of the time of day.
        Returns:
        the hour of the day
      • getMinuteOfHour

        public int getMinuteOfHour()
        Get the minutes portion of the time of day.
        Returns:
        the minute within the hour
      • getSecondOfMinute

        public int getSecondOfMinute()
        Get the seconds portion of the time of day.
        Returns:
        the second within the minute
      • getSubsecondMillis

        public int getSubsecondMillis()
        Get the millisecond portion of the time of day.
        Returns:
        the milliseconds within the second
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • now

        public static int now()
        Gets the current time of day in the default time zone as milliseconds since midnight.
        Returns:
        the number of milliseconds elapsed since midnight
      • now

        public static int now​(TimeZone tz)
        Gets the current time of day in the specified time zone as milliseconds since midnight.
        Parameters:
        tz - the time zone relative to which to interpret the current time
        Returns:
        the number of milliseconds elapsed since midnight