Package org.daiitech.naftah.builtin.time
Record Class NaftahTime.Time
java.lang.Object
java.lang.Record
org.daiitech.naftah.builtin.time.NaftahTime.Time
- Record Components:
hour- the hour of the dayminute- the minute of the hoursecond- optional second of the minutenano- optional nanosecond partisPM- 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
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thehourrecord component.private final BooleanThe field for theisPMrecord component.private final intThe field for theminuterecord component.private final IntegerThe field for thenanorecord component.private final IntegerThe field for thesecondrecord component. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.intReturns the hour converted to 24-hour format based on the AM/PM indicator.final inthashCode()Returns a hash code value for this object.inthour()Returns the value of thehourrecord component.isPM()Returns the value of theisPMrecord component.intminute()Returns the value of theminuterecord component.nano()Returns the value of thenanorecord component.static NaftahTime.TimeCreates aTimeinstance with the given hour, minute, optional second, nanosecond, and AM/PM indicator.second()Returns the value of thesecondrecord component.toString()Returns a string representation of thisTimein the format: "HH:mm[:ss[.nnnnnnnnn]] [AM/PM]".
-
Field Details
-
Constructor Details
-
Time
Creates an instance of aTimerecord class.
-
-
Method Details
-
of
Creates aTimeinstance with the given hour, minute, optional second, nanosecond, and AM/PM indicator.- Parameters:
hour- the hour of the dayminute- the minute of the hoursecond- optional second of the minutenano- optional nanosecond partisPM- true for PM, false for AM, null if 24-hour format- Returns:
- a new
Timeinstance - 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
Returns a string representation of thisTimein the format: "HH:mm[:ss[.nnnnnnnnn]] [AM/PM]".Optional seconds, nanoseconds, and AM/PM indicator are included if present.
-
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
hour
public int hour()Returns the value of thehourrecord component.- Returns:
- the value of the
hourrecord component
-
minute
public int minute()Returns the value of theminuterecord component.- Returns:
- the value of the
minuterecord component
-
second
Returns the value of thesecondrecord component.- Returns:
- the value of the
secondrecord component
-
nano
Returns the value of thenanorecord component.- Returns:
- the value of the
nanorecord component
-
isPM
Returns the value of theisPMrecord component.- Returns:
- the value of the
isPMrecord component
-