Package org.daiitech.naftah.builtin.time
Interface TimeSupport
- All Known Implementing Classes:
NaftahDateTime,NaftahTime
public interface TimeSupport
Provides arithmetic operations for
NaftahTemporalPoint instances,
including addition and subtraction of hours, minutes, seconds, and nanoseconds.
This interface can be implemented by NaftahTime or
used by NaftahDateTime to delegate time arithmetic.
- Author:
- Chakib Daii
-
Method Summary
Modifier and TypeMethodDescriptionintgetHour()Gets the hour-of-day field.default intgetMilli()Gets the millisecond-of-second from the time part of this temporal.intGets the minute-of-hour field.intgetNano()Gets the nano-of-second field.intGets the second-of-minute field.minusHours(long hoursToSubtract) Returns a new time instance with the specified number of hours subtracted.minusMinutes(long minutesToSubtract) Returns a new time instance with the specified number of minutes subtracted.minusNanos(long nanosToSubtract) Returns a new time instance with the specified number of nanoseconds subtracted.minusSeconds(long secondsToSubtract) Returns a new time instance with the specified number of seconds subtracted.plusHours(long hoursToAdd) Returns a new time instance with the specified number of hours added.plusMinutes(long minutesToAdd) Returns a new time instance with the specified number of minutes added.plusNanos(long nanosToAdd) Returns a new time instance with the specified number of nanoseconds added.plusSeconds(long secondsToAdd) Returns a new time instance with the specified number of seconds added.
-
Method Details
-
getHour
int getHour()Gets the hour-of-day field.- Returns:
- the hour-of-day, from 0 to 23
-
getMinute
int getMinute()Gets the minute-of-hour field.- Returns:
- the minute-of-hour, from 0 to 59
-
getSecond
int getSecond()Gets the second-of-minute field.- Returns:
- the second-of-minute, from 0 to 59
-
getMilli
default int getMilli()Gets the millisecond-of-second from the time part of this temporal.This value is derived from the nano-of-second field by dividing by
1_000_000.- Returns:
- the millisecond-of-second, from 0 to 999
-
getNano
int getNano()Gets the nano-of-second field.- Returns:
- the nano-of-second, from 0 to 999,999,999
-
plusHours
Returns a new time instance with the specified number of hours added.- Parameters:
hoursToAdd- the number of hours to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with hours added
-
plusMinutes
Returns a new time instance with the specified number of minutes added.- Parameters:
minutesToAdd- the number of minutes to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with minutes added
-
plusSeconds
Returns a new time instance with the specified number of seconds added.- Parameters:
secondsToAdd- the number of seconds to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with seconds added
-
plusNanos
Returns a new time instance with the specified number of nanoseconds added.- Parameters:
nanosToAdd- the number of nanoseconds to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with nanoseconds added
-
minusHours
Returns a new time instance with the specified number of hours subtracted.- Parameters:
hoursToSubtract- the number of hours to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with hours subtracted
-
minusMinutes
Returns a new time instance with the specified number of minutes subtracted.- Parameters:
minutesToSubtract- the number of minutes to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with minutes subtracted
-
minusSeconds
Returns a new time instance with the specified number of seconds subtracted.- Parameters:
secondsToSubtract- the number of seconds to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with seconds subtracted
-
minusNanos
Returns a new time instance with the specified number of nanoseconds subtracted.- Parameters:
nanosToSubtract- the number of nanoseconds to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with nanoseconds subtracted
-