Date

org.abh80.nf.core.time.Date
See theDate companion class
object Date

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

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Date.type

Members list

Value members

Concrete methods

def apply(j2000Offset: Int): Date

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 Date instance 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
def apply(year: Int, month: Month, day: Int): Date

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 Month enum.

year

The year of the date.

Attributes

Returns

A new Date instance representing the specified year, month, and day.

Example
 import core.time.util.DateUtil.Month
 val christmas: Date = Date(2024, Month.December, 25)
def apply(year: Int, days: Int): Date

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 Date instance 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)
def apply(year: Int, month: Int, day: Int): Date

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 Date instance 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
def apply(epoch: Date, j2000Offset: Int): Date

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 Date to use as the epoch.

j2000Offset

The number of days to offset from the epoch.

Attributes

Returns

A new Date instance 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
def now(): Date

Constructs a new Date instance from Instant.now

Constructs a new Date instance from Instant.now

This method creates a new Date object from the current instant of the time

Attributes

Returns

a Date instance representing the current Date

Concrete fields

val CXCSEC: Date

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

val GLONASS: Date

The GLONASS epoch date, which started on January 1, 1996

The GLONASS epoch date, which started on January 1, 1996

Attributes

val GPS: Date

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

val J2000_0: Date

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

val JULIAN: Date

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

val MJD: Date

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

val UNIX: Date

The Unix epoch, used as the starting point for Unix timestamps. Defined as January 1, 1970, at 00:00:00 UTC.

The Unix epoch, used as the starting point for Unix timestamps. Defined as January 1, 1970, at 00:00:00 UTC.

Attributes