Record Class NaftahTime
- Record Components:
time- the time componentzoneOrOffset- the optional time zone or offset componenttemporal- the resolvedTemporalrepresentation
- All Implemented Interfaces:
NaftahTemporal,NaftahTemporalPoint,TimeSupport
Temporal representation.
Implemented as a record with the components:
NaftahTime.Time– the hour, minute, optional second and nanosecond, and AM/PM indicatorNaftahTime.ZoneOrOffset– optional time zone or numeric offsetTemporal– the resolved temporal representation
This record implements NaftahTemporalPoint and is typically produced
after parsing Arabic time expressions.
- Author:
- Chakib Daii
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents the time component of an Arabic time expression.static final recordRepresents an Arabic time zone or numeric offset. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TemporalThe field for thetemporalrecord component.private final NaftahTime.TimeThe field for thetimerecord component.private final NaftahTime.ZoneOrOffsetThe field for thezoneOrOffsetrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionNaftahTime(NaftahTime.Time time, NaftahTime.ZoneOrOffset zoneOrOffset, Temporal temporal) Creates an instance of aNaftahTimerecord class. -
Method Summary
Modifier and TypeMethodDescription(package private) NaftahTimecompute(NaftahTemporalAmount arabicTemporalAmount, Function<TemporalAmount, Temporal> computeFunction) Computes a newArabicTimeby applying the given temporal computation.final booleanIndicates whether some other object is "equal to" this one.intgetHour()Gets the hour-of-day field.intGets the minute-of-hour field.intgetNano()Gets the nano-of-second field.intGets the second-of-minute field.final inthashCode()Returns a hash code value for this object.minus(NaftahTemporalAmount naftahTemporalAmount) Returns a newArabicTimeobtained by subtracting the given Arabic temporal amount from this time.minusHours(long hoursToSubtract) Returns a newArabicTimewith the specified number of hours subtracted.minusMinutes(long minutesToSubtract) Returns a newArabicTimewith the specified number of minutes subtracted.minusNanos(long nanosToSubtract) Returns a newArabicTimewith the specified number of nanoseconds subtracted.minusSeconds(long secondsToSubtract) Returns a newArabicTimewith the specified number of seconds subtracted.static NaftahTimenow()Obtains the current time using the system default time zone.static NaftahTimenow(NaftahTime.ZoneOrOffset zoneOrOffset) Obtains the current time using the specified zone or offset.static NaftahTimeof(int hour, int minute) Creates anArabicTimeinstance from hour and minute.static NaftahTimeof(int hour, int minute, int second) Creates anArabicTimeinstance from hour, minute, and second.static NaftahTimeof(int hour, int minute, int second, int nanoOfSecond) Creates anArabicTimeinstance from hour, minute, second, and nanosecond.static NaftahTimeof(int hour, int minute, int second, int nanoOfSecond, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from hour, minute, second, and nanosecond, optionally associated with a time zone or offset.static NaftahTimeof(int hour, int minute, int second, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from hour, minute, and second, optionally associated with a time zone or offset.static NaftahTimeof(int hour, int minute, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from hour and minute, optionally associated with a time zone or offset.static NaftahTimeof(NaftahTime.Time time, NaftahTime.ZoneOrOffset zoneOrOffset) Creates a newArabicTimeinstance using explicit components and resolves the backingTemporalautomatically.static NaftahTimeof(NaftahTime.Time time, NaftahTime.ZoneOrOffset zoneOrOffset, Temporal temporal) Creates a newArabicTimeinstance using explicit components.static NaftahTimeof(NaftahTime.ZoneOrOffset zoneOrOffset, Temporal temporal) Creates a newArabicTimeinstance by extracting time fields directly from aTemporalobject.static NaftahTimeofNanoOfDay(long nanoOfDay) Creates anArabicTimeinstance from the total number of nanoseconds since midnight.static NaftahTimeofNanoOfDay(long nanoOfDay, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from the total number of nanoseconds since midnight, optionally associated with a time zone or offset.static NaftahTimeofSecondOfDay(long secondOfDay) Creates anArabicTimeinstance from the total number of seconds since midnight.static NaftahTimeofSecondOfDay(long secondOfDay, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from the total number of seconds since midnight, optionally associated with a time zone or offset.plus(NaftahTemporalAmount naftahTemporalAmount) Returns a newArabicTimeobtained by adding the given Arabic temporal amount to this time.plusHours(long hoursToAdd) Returns a newArabicTimewith the specified number of hours added.plusMinutes(long minutesToAdd) Returns a newArabicTimewith the specified number of minutes added.plusNanos(long nanosToAdd) Returns a newArabicTimewith the specified number of nanoseconds added.plusSeconds(long secondsToAdd) Returns a newArabicTimewith the specified number of seconds added.temporal()Returns the value of thetemporalrecord component.time()Returns the value of thetimerecord component.toString()Returns a string representation of thisArabicTimein the format: "time zoneOrOffset".Returns the value of thezoneOrOffsetrecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.daiitech.naftah.builtin.time.NaftahTemporalPoint
greaterThan, greaterThanEquals, isEquals, lessThan, lessThanEquals, notEqualsMethods inherited from interface org.daiitech.naftah.builtin.time.TimeSupport
getMilli
-
Field Details
-
time
The field for thetimerecord component. -
zoneOrOffset
The field for thezoneOrOffsetrecord component. -
temporal
The field for thetemporalrecord component.
-
-
Constructor Details
-
NaftahTime
Creates an instance of aNaftahTimerecord class.- Parameters:
time- the value for thetimerecord componentzoneOrOffset- the value for thezoneOrOffsetrecord componenttemporal- the value for thetemporalrecord component
-
-
Method Details
-
now
Obtains the current time using the system default time zone.This method is equivalent to invoking
now(null).- Returns:
- the current
ArabicTime
-
now
Obtains the current time using the specified zone or offset.If
zoneOrOffsetisnull, the system default time zone is used.- Parameters:
zoneOrOffset- the zone or offset to use, ornullto use the system default- Returns:
- the current
ArabicTime
-
of
Creates anArabicTimeinstance from hour and minute.Seconds and nanoseconds default to
0.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)- Returns:
- a new
ArabicTimeinstance
-
of
Creates anArabicTimeinstance from hour and minute, optionally associated with a time zone or offset.The second and nanosecond fields are set to
0.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)zoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
of
Creates anArabicTimeinstance from hour, minute, and second.Nano-of-second defaults to
0.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)second- the second-of-minute (0–59)- Returns:
- a new
ArabicTimeinstance
-
of
Creates anArabicTimeinstance from hour, minute, and second, optionally associated with a time zone or offset.The nanosecond field is set to
0.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)second- the second-of-minute (0–59)zoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
of
Creates anArabicTimeinstance from hour, minute, second, and nanosecond.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)second- the second-of-minute (0–59)nanoOfSecond- the nanosecond-of-second (0–999,999,999)- Returns:
- a new
ArabicTimeinstance
-
of
public static NaftahTime of(int hour, int minute, int second, int nanoOfSecond, NaftahTime.ZoneOrOffset zoneOrOffset) Creates anArabicTimeinstance from hour, minute, second, and nanosecond, optionally associated with a time zone or offset.- Parameters:
hour- the hour-of-day (0–23)minute- the minute-of-hour (0–59)second- the second-of-minute (0–59)nanoOfSecond- the nanosecond-of-second (0–999,999,999)zoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
ofSecondOfDay
Creates anArabicTimeinstance from the total number of seconds since midnight.- Parameters:
secondOfDay- the second-of-day (0–86,399)- Returns:
- a new
ArabicTimeinstance
-
ofSecondOfDay
Creates anArabicTimeinstance from the total number of seconds since midnight, optionally associated with a time zone or offset.- Parameters:
secondOfDay- the second-of-day (0–86,399)zoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
ofNanoOfDay
Creates anArabicTimeinstance from the total number of nanoseconds since midnight.- Parameters:
nanoOfDay- the nano-of-day (0–86,399,999,999,999)- Returns:
- a new
ArabicTimeinstance
-
ofNanoOfDay
Creates anArabicTimeinstance from the total number of nanoseconds since midnight, optionally associated with a time zone or offset.- Parameters:
nanoOfDay- the nano-of-day (0–86,399,999,999,999)zoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
of
public static NaftahTime of(NaftahTime.Time time, NaftahTime.ZoneOrOffset zoneOrOffset, Temporal temporal) Creates a newArabicTimeinstance using explicit components.This factory method is typically used when the parsed time, optional zone/offset, and the resolved
Temporalrepresentation are already available.- Parameters:
time- the logical time component (hour, minute, second, nano, AM/PM)zoneOrOffset- the optional time zone or offset information, may benulltemporal- the resolvedTemporalrepresentation backing this time- Returns:
- a new
ArabicTimeinstance
-
of
Creates a newArabicTimeinstance using explicit components and resolves the backingTemporalautomatically.- Parameters:
time- the logical time component, not nullzoneOrOffset- the optional time zone or offset, may be null- Returns:
- a new
ArabicTimeinstance, not null
-
of
Creates a newArabicTimeinstance by extracting time fields directly from aTemporalobject.The following fields are resolved if supported by the temporal:
ChronoField.HOUR_OF_DAYChronoField.MINUTE_OF_HOURChronoField.SECOND_OF_MINUTEChronoField.NANO_OF_SECOND
0.The resulting
NaftahTime.Timeinstance is created using a 24-hour clock representation, with no AM/PM marker.- Parameters:
zoneOrOffset- the optional time zone or offset information, may benulltemporal- the temporal object from which time fields are extracted- Returns:
- a new
ArabicTimeinstance - Throws:
IllegalArgumentException- if the temporal cannot represent a valid time
-
getHour
public int getHour()Gets the hour-of-day field.- Specified by:
getHourin interfaceTimeSupport- Returns:
- the hour-of-day, from 0 to 23
-
getMinute
public int getMinute()Gets the minute-of-hour field.- Specified by:
getMinutein interfaceTimeSupport- Returns:
- the minute-of-hour, from 0 to 59
-
getSecond
public int getSecond()Gets the second-of-minute field.- Specified by:
getSecondin interfaceTimeSupport- Returns:
- the second-of-minute, from 0 to 59
-
getNano
public int getNano()Gets the nano-of-second field.- Specified by:
getNanoin interfaceTimeSupport- Returns:
- the nano-of-second, from 0 to 999,999,999
-
plus
Returns a newArabicTimeobtained by adding the given Arabic temporal amount to this time.- Specified by:
plusin interfaceNaftahTemporalPoint- Parameters:
naftahTemporalAmount- the temporal amount to add- Returns:
- a new
ArabicTimeinstance
-
plusHours
Returns a newArabicTimewith the specified number of hours added.If
hoursToAddis zero, this instance is returned unchanged.- Specified by:
plusHoursin interfaceTimeSupport- Parameters:
hoursToAdd- the number of hours to add, may be negative- Returns:
- a new
ArabicTimeinstance with the hours added
-
plusMinutes
Returns a newArabicTimewith the specified number of minutes added.If
minutesToAddis zero, this instance is returned unchanged.- Specified by:
plusMinutesin interfaceTimeSupport- Parameters:
minutesToAdd- the number of minutes to add, may be negative- Returns:
- a new
ArabicTimeinstance with the minutes added
-
plusSeconds
Returns a newArabicTimewith the specified number of seconds added.If
secondsToAddis zero, this instance is returned unchanged.- Specified by:
plusSecondsin interfaceTimeSupport- Parameters:
secondsToAdd- the number of seconds to add, may be negative- Returns:
- a new
ArabicTimeinstance with the seconds added
-
plusNanos
Returns a newArabicTimewith the specified number of nanoseconds added.If
nanosToAddis zero, this instance is returned unchanged.- Specified by:
plusNanosin interfaceTimeSupport- Parameters:
nanosToAdd- the number of nanoseconds to add, may be negative- Returns:
- a new
ArabicTimeinstance with the nanoseconds added
-
minus
Returns a newArabicTimeobtained by subtracting the given Arabic temporal amount from this time.- Specified by:
minusin interfaceNaftahTemporalPoint- Parameters:
naftahTemporalAmount- the temporal amount to subtract- Returns:
- a new
ArabicTimeinstance
-
minusHours
Returns a newArabicTimewith the specified number of hours subtracted.If
hoursToSubtractis zero, this instance is returned unchanged.- Specified by:
minusHoursin interfaceTimeSupport- Parameters:
hoursToSubtract- the number of hours to subtract, may be negative- Returns:
- a new
ArabicTimeinstance with the hours subtracted
-
minusMinutes
Returns a newArabicTimewith the specified number of minutes subtracted.If
minutesToSubtractis zero, this instance is returned unchanged.- Specified by:
minusMinutesin interfaceTimeSupport- Parameters:
minutesToSubtract- the number of minutes to subtract, may be negative- Returns:
- a new
ArabicTimeinstance with the minutes subtracted
-
minusSeconds
Returns a newArabicTimewith the specified number of seconds subtracted.If
secondsToSubtractis zero, this instance is returned unchanged.- Specified by:
minusSecondsin interfaceTimeSupport- Parameters:
secondsToSubtract- the number of seconds to subtract, may be negative- Returns:
- a new
ArabicTimeinstance with the seconds subtracted
-
minusNanos
Returns a newArabicTimewith the specified number of nanoseconds subtracted.If
nanosToSubtractis zero, this instance is returned unchanged.- Specified by:
minusNanosin interfaceTimeSupport- Parameters:
nanosToSubtract- the number of nanoseconds to subtract, may be negative- Returns:
- a new
ArabicTimeinstance with the nanoseconds subtracted
-
compute
NaftahTime compute(NaftahTemporalAmount arabicTemporalAmount, Function<TemporalAmount, Temporal> computeFunction) Computes a newArabicTimeby applying the given temporal computation.Only duration-based arithmetic is supported for time-only values. Period-based operations are not permitted.
- Parameters:
arabicTemporalAmount- the temporal amount to applycomputeFunction- the temporal computation function- Returns:
- a new
ArabicTimeinstance - Throws:
IllegalArgumentException- if the operation is not supported
-
toString
Returns a string representation of thisArabicTimein the format: "time zoneOrOffset".If a
NaftahTime.ZoneOrOffsetis present, it is appended after the time. Otherwise, only the time component is returned. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
time
Returns the value of thetimerecord component.- Returns:
- the value of the
timerecord component
-
zoneOrOffset
Returns the value of thezoneOrOffsetrecord component.- Returns:
- the value of the
zoneOrOffsetrecord component
-
temporal
Returns the value of thetemporalrecord component.- Specified by:
temporalin interfaceNaftahTemporalPoint- Returns:
- the value of the
temporalrecord component
-