Record Class NaftahTime.Time

java.lang.Object
java.lang.Record
org.daiitech.naftah.builtin.time.NaftahTime.Time
Record Components:
hour - the hour of the day
minute - the minute of the hour
second - optional second of the minute
nano - optional nanosecond part
isPM - true for PM, false for AM, null if 24-hour format
Enclosing class:
NaftahTime

public static record NaftahTime.Time(int hour, int minute, Integer second, Integer nano, Boolean isPM) extends Record
Represents the time component of an Arabic time expression.

Stores hour, minute, optional second and nanosecond values, and optionally an AM/PM indicator.

Validates the values to ensure they are within correct ranges depending on 12-hour or 24-hour format.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The field for the hour record component.
    private final Boolean
    The field for the isPM record component.
    private final int
    The field for the minute record component.
    private final Integer
    The field for the nano record component.
    private final Integer
    The field for the second record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Time(int hour, int minute, Integer second, Integer nano, Boolean isPM)
    Creates an instance of a Time record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the hour converted to 24-hour format based on the AM/PM indicator.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the hour record component.
    Returns the value of the isPM record component.
    int
    Returns the value of the minute record component.
    Returns the value of the nano record component.
    of(int hour, int minute, Integer second, Integer nano, Boolean isPM)
    Creates a Time instance with the given hour, minute, optional second, nanosecond, and AM/PM indicator.
    Returns the value of the second record component.
    Returns a string representation of this Time in the format: "HH:mm[:ss[.nnnnnnnnn]] [AM/PM]".

    Methods inherited from class java.lang.Object

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

    • hour

      private final int hour
      The field for the hour record component.
    • minute

      private final int minute
      The field for the minute record component.
    • second

      private final Integer second
      The field for the second record component.
    • nano

      private final Integer nano
      The field for the nano record component.
    • isPM

      private final Boolean isPM
      The field for the isPM record component.
  • Constructor Details

    • Time

      public Time(int hour, int minute, Integer second, Integer nano, Boolean isPM)
      Creates an instance of a Time record class.
      Parameters:
      hour - the value for the hour record component
      minute - the value for the minute record component
      second - the value for the second record component
      nano - the value for the nano record component
      isPM - the value for the isPM record component
  • Method Details

    • of

      public static NaftahTime.Time of(int hour, int minute, Integer second, Integer nano, Boolean isPM)
      Creates a Time instance with the given hour, minute, optional second, nanosecond, and AM/PM indicator.
      Parameters:
      hour - the hour of the day
      minute - the minute of the hour
      second - optional second of the minute
      nano - optional nanosecond part
      isPM - true for PM, false for AM, null if 24-hour format
      Returns:
      a new Time instance
      Throws:
      IllegalArgumentException - if any value is out of valid range
    • getHour24

      public int getHour24()
      Returns the hour converted to 24-hour format based on the AM/PM indicator.
      Returns:
      the hour in 24-hour format
    • toString

      public String toString()
      Returns a string representation of this Time in the format: "HH:mm[:ss[.nnnnnnnnn]] [AM/PM]".

      Optional seconds, nanoseconds, and AM/PM indicator are included if present.

      Specified by:
      toString in class Record
      Returns:
      a formatted string representing the time
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hour

      public int hour()
      Returns the value of the hour record component.
      Returns:
      the value of the hour record component
    • minute

      public int minute()
      Returns the value of the minute record component.
      Returns:
      the value of the minute record component
    • second

      public Integer second()
      Returns the value of the second record component.
      Returns:
      the value of the second record component
    • nano

      public Integer nano()
      Returns the value of the nano record component.
      Returns:
      the value of the nano record component
    • isPM

      public Boolean isPM()
      Returns the value of the isPM record component.
      Returns:
      the value of the isPM record component