Package org.daiitech.naftah.builtin.time
Interface DateSupport
- All Known Implementing Classes:
NaftahDate,NaftahDateTime
public interface DateSupport
Provides arithmetic operations for
NaftahTemporalPoint instances,
including addition and subtraction of years, months, weeks, and days.
This interface can be implemented by NaftahDate or
used by NaftahDateTime to delegate date arithmetic.
- Author:
- Chakib Daii
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the day-of-month component of this date.Returns the day of the week as an Naftah string for this date.intReturns the day-of-year for this date according to its chronology.getMonth()Returns the Naftah name of the month for this date.intReturns the numeric month value (1–12) of this date.intgetYear()Returns the year component of this date.booleanChecks if the year of this date is a leap year in its chronology.intReturns the length of the month in days for this date.intReturns the length of the year in days for this date.minusDays(long daysToSubtract) Returns a new date instance with the specified number of days subtracted.minusMonths(long monthsToSubtract) Returns a new date instance with the specified number of months subtracted.minusWeeks(long weeksToSubtract) Returns a new date instance with the specified number of weeks subtracted.minusYears(long yearsToSubtract) Returns a new date instance with the specified number of years subtracted.plusDays(long daysToAdd) Returns a new date instance with the specified number of days added.plusMonths(long monthsToAdd) Returns a new date instance with the specified number of months added.plusWeeks(long weeksToAdd) Returns a new date instance with the specified number of weeks added.plusYears(long yearsToAdd) Returns a new date instance with the specified number of years added.longConverts this date to the number of days since the epoch (1970-01-01) in the ISO calendar.
-
Method Details
-
toEpochDay
long toEpochDay()Converts this date to the number of days since the epoch (1970-01-01) in the ISO calendar.- Returns:
- the epoch day count
-
getYear
int getYear()Returns the year component of this date.- Returns:
- the year value
-
getMonthValue
int getMonthValue()Returns the numeric month value (1–12) of this date.- Returns:
- the month value
-
getMonth
String getMonth()Returns the Naftah name of the month for this date.- Returns:
- the Naftah month name
-
getDayOfMonth
int getDayOfMonth()Returns the day-of-month component of this date.- Returns:
- the day of the month
-
getDayOfYear
int getDayOfYear()Returns the day-of-year for this date according to its chronology.- Returns:
- the day of the year (1–365 or 1–366 for leap years)
-
getDayOfWeek
String getDayOfWeek()Returns the day of the week as an Naftah string for this date.The calculation is based on the epoch day of the underlying
ChronoLocalDate.- Returns:
- the Naftah name of the day of the week
-
isLeapYear
boolean isLeapYear()Checks if the year of this date is a leap year in its chronology.- Returns:
trueif the year is a leap year,falseotherwise
-
lengthOfMonth
int lengthOfMonth()Returns the length of the month in days for this date.The length is determined according to the chronology of the calendar.
- Returns:
- the number of days in the month
-
lengthOfYear
int lengthOfYear()Returns the length of the year in days for this date.The number of days depends on the chronology of the date:
- For Gregorian years (ISO chronology), leap years return 366 days, and non-leap years return 365 days.
- For Hijri years, leap years return 355 days, and non-leap years return 354 days.
- Returns:
- the number of days in the year according to its chronology
-
plusYears
Returns a new date instance with the specified number of years added.- Parameters:
yearsToAdd- the number of years to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with years added
-
plusMonths
Returns a new date instance with the specified number of months added.- Parameters:
monthsToAdd- the number of months to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with months added
-
plusWeeks
Returns a new date instance with the specified number of weeks added.- Parameters:
weeksToAdd- the number of weeks to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with weeks added
-
plusDays
Returns a new date instance with the specified number of days added.- Parameters:
daysToAdd- the number of days to add, may be negative- Returns:
- a new
NaftahTemporalPointinstance with days added
-
minusYears
Returns a new date instance with the specified number of years subtracted.- Parameters:
yearsToSubtract- the number of years to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with years subtracted
-
minusMonths
Returns a new date instance with the specified number of months subtracted.- Parameters:
monthsToSubtract- the number of months to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with months subtracted
-
minusWeeks
Returns a new date instance with the specified number of weeks subtracted.- Parameters:
weeksToSubtract- the number of weeks to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with weeks subtracted
-
minusDays
Returns a new date instance with the specified number of days subtracted.- Parameters:
daysToSubtract- the number of days to subtract, may be negative- Returns:
- a new
NaftahTemporalPointinstance with days subtracted
-