Factory methods for creating Date instances.
This companion object provides various apply methods to construct Date objects using different date components and epoch references. These methods offer flexibility in creating Date instances from J2000 offsets, year/month/day combinations, or year/day-of-year combinations.
Attributes
Members list
Value members
Concrete methods
Constructs a Date instance from a J2000 day offset.
Constructs a Date instance from a J2000 day offset.
This method allows creating a Date object directly from the number of days since the J2000 epoch (January 1, 2000).
Value parameters
- j2000Offset
-
The number of days since January 1, 2000.
Attributes
- Returns
-
A new
Dateinstance representing the specified J2000 offset. - Example
-
val epoch: Date = Date(0) // January 1, 2000 val futureDate: Date = Date(365) // January 1, 2001 val pastDate: Date = Date(-365) // January 1, 1999
Constructs a Date instance from year, month (as a Month enum), and day components.
Constructs a Date instance from year, month (as a Month enum), and day components.
This method facilitates creating a Date object using a year, a Month enum value, and a day of the month. It internally converts the Month enum to its integer representation.
Value parameters
- day
-
The day of the month.
- month
-
The month of the year as a
Monthenum. - year
-
The year of the date.
Attributes
- Returns
-
A new
Dateinstance representing the specified year, month, and day. - Example
-
import core.time.util.DateUtil.Month val christmas: Date = Date(2024, Month.December, 25)
Constructs a Date instance from a year and the day of the year.
Constructs a Date instance from a year and the day of the year.
This method creates a Date object from a given year and the day of the year (where January 1st is day 1). It calculates the corresponding date by adding the specified number of days to the last day of the previous year.
Value parameters
- days
-
The day of the year (1-366).
- year
-
The year of the date.
Attributes
- Returns
-
A new
Dateinstance representing the specified year and day of the year. - Example
-
val newYearsDay: Date = Date(2024, 1) // January 1, 2024 val lastDayOfYear: Date = Date(2024, 366) // December 31, 2024 (if leap year)
Constructs a Date instance from year, month, and day components.
Constructs a Date instance from year, month, and day components.
This method is the primary way to create a Date object from its individual components: year, month, and day.
Value parameters
- day
-
The day of the month.
- month
-
The month of the year (1-12).
- year
-
The year of the date.
Attributes
- Returns
-
A new
Dateinstance representing the specified year, month, and day. - Throws
-
IllegalArgumentException
if the date components form an invalid date
- Example
-
val independenceDay: Date = Date(1776, 7, 4) // July 4, 1776
Constructs a Date instance from an epoch Date and a J2000 day offset.
Constructs a Date instance from an epoch Date and a J2000 day offset.
This method creates a new Date object relative to a specified epoch Date by adding a J2000 day offset to the epoch's J2000 day number.
Value parameters
- epoch
-
The base
Dateto use as the epoch. - j2000Offset
-
The number of days to offset from the epoch.
Attributes
- Returns
-
A new
Dateinstance representing the date at the specified offset from the epoch. - Example
-
val epoch: Date = Date(2020, 1, 1) val futureDate: Date = Date(epoch, 100) // 100 days after January 1, 2020
Concrete fields
The CXCSEC epoch, used by the Chandra X-ray Observatory. Defined as January 1, 1998, at 00:00:00 TT.
The CXCSEC epoch, used by the Chandra X-ray Observatory. Defined as January 1, 1998, at 00:00:00 TT.
Attributes
The GLONASS epoch date, which started on January 1, 1996
The GLONASS epoch date, which started on January 1, 1996
Attributes
The GPS epoch, used by the Global Positioning System. Defined as January 6, 1980, at 00:00:00 UTC.
The GPS epoch, used by the Global Positioning System. Defined as January 6, 1980, at 00:00:00 UTC.
Attributes
The J2000.0 epoch, which is the fundamental epoch for the ICRF reference frame. Defined as January 1, 2000, at 12:00 TT (Terrestrial Time).
The J2000.0 epoch, which is the fundamental epoch for the ICRF reference frame. Defined as January 1, 2000, at 12:00 TT (Terrestrial Time).
Attributes
The Julian epoch, which marks the beginning of the Julian calendar. Defined as January 1, 4713, BCE at 12:00 UT.
The Julian epoch, which marks the beginning of the Julian calendar. Defined as January 1, 4713, BCE at 12:00 UT.
Attributes
The modified julian date, which started at midnight on November 17, 1858 (Gregorian calendar).
The modified julian date, which started at midnight on November 17, 1858 (Gregorian calendar).
Attributes
NavIC system time start epoch is 00:00 UT on Sunday, August 22nd 1999 (midnight between August 21st and 22nd). The first week number rollover event occurred on April 06, 2019. The system time is currently in the second epoch.
NavIC system time start epoch is 00:00 UT on Sunday, August 22nd 1999 (midnight between August 21st and 22nd). The first week number rollover event occurred on April 06, 2019. The system time is currently in the second epoch.