The Julian Day is a standard way of expressing date and time commonly used in the scientific community. It is expressed as a decimal number of whole days where days start at midday. This class represents variations on Julian Days that count whole days from midnight.
The fields are implemented relative to EPOCH_DAY
.
The fields are supported, and can be queried and set if EPOCH_DAY
is available.
The fields work with all chronologies.
Implementation Specification
This is an immutable and thread-safe class.
Modifier and Type | Class and Description |
---|---|
private static enum | JulianFields.
Implementation of JulianFields. |
Modifier and Type | Field and Description |
---|---|
public static final TemporalField | JULIAN_DAY
Julian Day field. |
private static final long | JULIAN_DAY_OFFSET
The offset from Julian to EPOCH DAY. |
public static final TemporalField | MODIFIED_JULIAN_DAY
Modified Julian Day field. |
public static final TemporalField | RATA_DIE
Rata Die field. |
Access | Constructor and Description |
---|---|
private |
JULIAN_DAY | back to summary |
---|---|
public static final TemporalField JULIAN_DAY Julian Day field. This is an integer-based version of the Julian Day Number. Julian Day is a well-known system that represents the count of whole days since day 0, which is defined to be January 1, 4713 BCE in the Julian calendar, and -4713-11-24 Gregorian. The field has "JulianDay" as 'name', and 'DAYS' as 'baseUnit'. The field always refers to the local date-time, ignoring the offset or zone.
For date-times, 'JULIAN_DAY.getFrom()' assumes the same value from
midnight until just before the next midnight.
When 'JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered.
'JULIAN_DAY.adjustInto()' and 'JULIAN_DAY.getFrom()' only apply to In the resolving phase of parsing, a date can be created from a Julian Day field. In strict mode and smart mode the Julian Day value is validated against the range of valid values. In lenient mode no validation occurs. Astronomical and Scientific NotesThe standard astronomical definition uses a fraction to indicate the time-of-day, where each day is counted from midday to midday. For example, a fraction of 0 represents midday, a fraction of 0.25 represents 18:00, a fraction of 0.5 represents midnight and a fraction of 0.75 represents 06:00.
By contrast, this implementation has no fractional part, and counts
days from midnight to midnight.
This implementation uses an integer and days starting at midnight.
The integer value for the Julian Day Number is the astronomical Julian Day value at midday
of the date in question.
This amounts to the astronomical Julian Day, rounded to an integer | ISO date | Julian Day Number | Astronomical Julian Day | | 1970-01-01T00:00 | 2,440,588 | 2,440,587.5 | | 1970-01-01T06:00 | 2,440,588 | 2,440,587.75 | | 1970-01-01T12:00 | 2,440,588 | 2,440,588.0 | | 1970-01-01T18:00 | 2,440,588 | 2,440,588.25 | | 1970-01-02T00:00 | 2,440,589 | 2,440,588.5 | | 1970-01-02T06:00 | 2,440,589 | 2,440,588.75 | | 1970-01-02T12:00 | 2,440,589 | 2,440,589.0 | Julian Days are sometimes taken to imply Universal Time or UTC, but this implementation always uses the Julian Day number for the local date, regardless of the offset or time-zone. |
JULIAN_DAY_OFFSET | back to summary |
---|---|
private static final long JULIAN_DAY_OFFSET The offset from Julian to EPOCH DAY. |
MODIFIED_JULIAN_DAY | back to summary |
---|---|
public static final TemporalField MODIFIED_JULIAN_DAY Modified Julian Day field.
This is an integer-based version of the Modified Julian Day Number.
Modified Julian Day (MJD) is a well-known system that counts days continuously.
It is defined relative to astronomical Julian Day as
For date-times, 'MODIFIED_JULIAN_DAY.getFrom()' assumes the same value from
midnight until just before the next midnight.
When 'MODIFIED_JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered.
'MODIFIED_JULIAN_DAY.adjustInto()' and 'MODIFIED_JULIAN_DAY.getFrom()' only apply to This implementation is an integer version of MJD with the decimal part rounded to floor. In the resolving phase of parsing, a date can be created from a Modified Julian Day field. In strict mode and smart mode the Modified Julian Day value is validated against the range of valid values. In lenient mode no validation occurs. Astronomical and Scientific Notes| ISO date | Modified Julian Day | Decimal MJD | | 1970-01-01T00:00 | 40,587 | 40,587.0 | | 1970-01-01T06:00 | 40,587 | 40,587.25 | | 1970-01-01T12:00 | 40,587 | 40,587.5 | | 1970-01-01T18:00 | 40,587 | 40,587.75 | | 1970-01-02T00:00 | 40,588 | 40,588.0 | | 1970-01-02T06:00 | 40,588 | 40,588.25 | | 1970-01-02T12:00 | 40,588 | 40,588.5 |Modified Julian Days are sometimes taken to imply Universal Time or UTC, but this implementation always uses the Modified Julian Day for the local date, regardless of the offset or time-zone. |
RATA_DIE | back to summary |
---|---|
public static final TemporalField RATA_DIE Rata Die field. Rata Die counts whole days continuously starting day 1 at midnight at the beginning of 0001-01-01 (ISO). The field always refers to the local date-time, ignoring the offset or zone.
For date-times, 'RATA_DIE.getFrom()' assumes the same value from
midnight until just before the next midnight.
When 'RATA_DIE.adjustInto()' is applied to a date-time, the time of day portion remains unaltered.
'RATA_DIE.adjustInto()' and 'RATA_DIE.getFrom()' only apply to In the resolving phase of parsing, a date can be created from a Rata Die field. In strict mode and smart mode the Rata Die value is validated against the range of valid values. In lenient mode no validation occurs. |
JulianFields | back to summary |
---|---|
private JulianFields() Restricted constructor. |
Modifier and Type | Field and Description |
---|---|
private final transient TemporalUnit | |
public static final JulianFields. | |
public static final JulianFields. | |
private final transient String | name
Hides java. |
private final transient long | |
private final transient ValueRange | |
private final transient TemporalUnit | |
public static final JulianFields. |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public <R extends Temporal> R | adjustInto(R
the temporal object to adjust, not null temporal, long the new value of the field newValue)Implements java. Returns a copy of the specified temporal object with the value of this field set. |
public TemporalUnit | getBaseUnit()
Implements java. Gets the unit that the field is measured in. The unit of the field is the period that varies within the range. |
public long | getFrom(TemporalAccessor
the temporal object to query, not null temporal)Implements java. Gets the value of this field from the specified temporal object. |
public TemporalUnit | getRangeUnit()
Implements java. Gets the range that the field is bound by. |
public boolean | isDateBased()
Implements java. Checks if this field represents a component of a date. |
public boolean | isSupportedBy(TemporalAccessor
the temporal object to query, not null temporal)Implements java. Checks if this field is supported by the temporal object. |
public boolean | isTimeBased()
Implements java. Checks if this field represents a component of a time. |
public ValueRange | range()
Implements java. Gets the range of valid values for the field. |
public ValueRange | rangeRefinedBy(TemporalAccessor
the temporal object used to refine the result, not null temporal)Implements java. Get the range of valid values for this field using the temporal object to refine the result. |
public ChronoLocalDate | resolve(Map<TemporalField, Long>
the map of fields to values, which can be updated, not null fieldValues, TemporalAccessor the partially complete temporal to query for zone and
chronology; querying for other things is undefined and not recommended, not null partialTemporal, ResolverStyle the requested type of resolve, not null resolverStyle)Overrides default java. Resolves this field to provide a simpler alternative or a date. |
public String | toString()
Overrides java. Implements java. Gets a descriptive name for the field. |
public static JulianFields. | |
public static JulianFields. |
baseUnit | back to summary |
---|---|
private final transient TemporalUnit baseUnit |
JULIAN_DAY | back to summary |
---|---|
public static final JulianFields. |
MODIFIED_JULIAN_DAY | back to summary |
---|---|
public static final JulianFields. |
name | back to summary |
---|---|
private final transient String name Hides java. |
offset | back to summary |
---|---|
private final transient long offset |
range | back to summary |
---|---|
private final transient ValueRange range |
rangeUnit | back to summary |
---|---|
private final transient TemporalUnit rangeUnit |
RATA_DIE | back to summary |
---|---|
public static final JulianFields. |
Field | back to summary |
---|---|
private Field(String name, TemporalUnit baseUnit, TemporalUnit rangeUnit, long offset) |
adjustInto | back to summary |
---|---|
public <R extends Temporal> R adjustInto(R temporal, long newValue) Implements java. Doc from java. Returns a copy of the specified temporal object with the value of this field set.
This returns a new temporal object based on the specified one with the value for
this field changed. For example, on a In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then changing the month to February would be unclear. In cases like this, the implementation is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February in this example.
There are two equivalent ways of using this method.
The first is to invoke this method directly.
The second is to use // these two lines are equivalent, but the second approach is recommended temporal = thisField.adjustInto(temporal); temporal = temporal.with(thisField);It is recommended to use the second approach, with(TemporalField) ,
as it is a lot clearer to read in code.
Implementations should perform any queries or calculations using the fields
available in Implementations must not alter the specified temporal object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
|
getBaseUnit | back to summary |
---|---|
public TemporalUnit getBaseUnit() Implements java. Doc from java. Gets the unit that the field is measured in.
The unit of the field is the period that varies within the range.
For example, in the field 'MonthOfYear', the unit is 'Months'.
See also
|
getFrom | back to summary |
---|---|
public long getFrom(TemporalAccessor temporal) Implements java. Doc from java. Gets the value of this field from the specified temporal object. This queries the temporal object for the value of this field.
There are two equivalent ways of using this method.
The first is to invoke this method directly.
The second is to use // these two lines are equivalent, but the second approach is recommended temporal = thisField.getFrom(temporal); temporal = temporal.getLong(thisField);It is recommended to use the second approach, getLong(TemporalField) ,
as it is a lot clearer to read in code.
Implementations should perform any queries or calculations using the fields
available in
|
getRangeUnit | back to summary |
---|---|
public TemporalUnit getRangeUnit() Implements java. Doc from java. Gets the range that the field is bound by.
The range of the field is the period that the field varies within.
For example, in the field 'MonthOfYear', the range is 'Years'.
See also The range is never null. For example, the 'Year' field is shorthand for 'YearOfForever'. It therefore has a unit of 'Years' and a range of 'Forever'.
|
isDateBased | back to summary |
---|---|
public boolean isDateBased() Implements java. Doc from java. Checks if this field represents a component of a date.
A field is date-based if it can be derived from
|
isSupportedBy | back to summary |
---|---|
public boolean isSupportedBy(TemporalAccessor temporal) Implements java. Doc from java. Checks if this field is supported by the temporal object. This determines whether the temporal accessor supports this field. If this returns false, then the temporal cannot be queried for this field.
There are two equivalent ways of using this method.
The first is to invoke this method directly.
The second is to use // these two lines are equivalent, but the second approach is recommended temporal = thisField.isSupportedBy(temporal); temporal = temporal.isSupported(thisField);It is recommended to use the second approach, isSupported(TemporalField) ,
as it is a lot clearer to read in code.
Implementations should determine whether they are supported using the fields
available in
|
isTimeBased | back to summary |
---|---|
public boolean isTimeBased() Implements java. Doc from java. Checks if this field represents a component of a time.
A field is time-based if it can be derived from
|
range | back to summary |
---|---|
public ValueRange range() Implements java. Doc from java. Gets the range of valid values for the field.
All fields can be expressed as a Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.
|
rangeRefinedBy | back to summary |
---|---|
public ValueRange rangeRefinedBy(TemporalAccessor temporal) Implements java. Doc from java. Get the range of valid values for this field using the temporal object to refine the result.
This uses the temporal object to find the range of valid values for the field.
This is similar to
There are two equivalent ways of using this method.
The first is to invoke this method directly.
The second is to use // these two lines are equivalent, but the second approach is recommended temporal = thisField.rangeRefinedBy(temporal); temporal = temporal.range(thisField);It is recommended to use the second approach, range(TemporalField) ,
as it is a lot clearer to read in code.
Implementations should perform any queries or calculations using the fields
available in
|
resolve | back to summary |
---|---|
public ChronoLocalDate resolve(Map<TemporalField, Long> fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) Overrides default java. Doc from java. Resolves this field to provide a simpler alternative or a date.
This method is invoked during the resolve phase of parsing.
It is designed to allow application defined fields to be simplified into
more standard fields, such as those on Applications should not normally invoke this method directly.
|
toString | back to summary |
---|---|
public String toString() Overrides java. Implements java. Doc from java. Gets a descriptive name for the field.
The should be of the format 'BaseOfRange', such as 'MonthOfYear',
unless the field has a range of |
valueOf | back to summary |
---|---|
public static JulianFields. |
values | back to summary |
---|---|
public static JulianFields. |