Class DateTimes
- Author:
- Quentin Ligier
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull Hl7Dtm
completeToEarliestInstant
(@NonNull org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp timestamp) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the start of the year, month, day, hour and minute if needed (i.e.static @NonNull Hl7Dtm
completeToEarliestInstant
(@NonNull Hl7Dtm hl7Dtm) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the start of the year, month, day, hour and minute if needed (i.e.static @NonNull Hl7Dtm
completeToLatestInstant
(@NonNull org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp timestamp) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the end of the year, month, day, hour and minute if needed (i.e.static @NonNull Hl7Dtm
completeToLatestInstant
(@NonNull Hl7Dtm hl7Dtm) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the end of the year, month, day, hour and minute if needed (i.e.static @NonNull ZonedDateTime
getZonedDateTime
(@NonNull Instant instant) Deprecated, for removal: This API element is subject to removal in a future version.static @NonNull ZonedDateTime
getZonedDateTime
(@NonNull Instant instant, @NonNull ZoneId zone) Converts anInstant
to aZonedDateTime
.static @NonNull TS
toDatetimeTs
(@NonNull TemporalAccessor temporal) Deprecated, for removal: This API element is subject to removal in a future version.usetoDatetimeTs(TemporalAccessor, ZoneId)
instead, to control the time zone.static @NonNull TS
toDatetimeTs
(@NonNull TemporalAccessor temporal, @NonNull ZoneId zone) static @NonNull TS
toDateTs
(@NonNull TemporalAccessor temporal) Deprecated, for removal: This API element is subject to removal in a future version.usetoDateTs(TemporalAccessor, ZoneId)
instead, to control the time zone.static @NonNull TS
toDateTs
(@NonNull TemporalAccessor temporal, ZoneId zone) static @NonNull String
Deprecated, for removal: This API element is subject to removal in a future version.usetoHl7Dtm(Instant, ZoneId)
instead, to control the time zone.static @NonNull String
Formats anInstant
to an HL7 DTM.static @NonNull Instant
static @Nullable LocalDate
toLocalDate
(@NonNull TS ts) Converts aTS
(TS.CH.TZ, Time Stamp) to a local date.
-
Method Details
-
completeToEarliestInstant
Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the start of the year, month, day, hour and minute if needed (i.e. sets it to the earliest instant covered by the partial date). The DTM value must be given in UTC.For example, if the value "201903" is given, the day is fixed to the start of the month (the first of march) and the time is set to 00:00:00, which results in: "20190301000000".
If the HL7 DTM is already precise to the fraction of seconds, it will be returned as-is.
- Parameters:
hl7Dtm
- The HL7 DTM-formatted dateTime to process.- Returns:
- the full precision dateTime.
-
completeToLatestInstant
Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the end of the year, month, day, hour and minute if needed (i.e. sets it to the latest instant covered by the partial date). The DTM value must be given in UTC.By example, if the value "201903" is given, the day is fixed to the end of the month (the last of march) and the time is set to the end of the day (usually 23:59:59), which results in: "20190331235959".
If the HL7 DTM is already precise to the fraction of seconds, it will be returned as-is.
- Parameters:
hl7Dtm
- The HL7 DTM-formatted dateTime to process.- Returns:
- the full precision dateTime.
-
completeToEarliestInstant
public static @NonNull Hl7Dtm completeToEarliestInstant(@NonNull org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp timestamp) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the start of the year, month, day, hour and minute if needed (i.e. sets it to the earliest instant covered by the partial date). The DTM value must be given in UTC.For example, if the value "201903" is given, the day is fixed to the start of the month (the first of march) and the time is set to 00:00:00, which results in: "20190301000000".
If the HL7 DTM is already precise to the fraction of seconds, it will be returned as-is.
- Parameters:
timestamp
- The HL7 DTM-formatted dateTime to process.- Returns:
- the full precision dateTime.
-
completeToLatestInstant
public static @NonNull Hl7Dtm completeToLatestInstant(@NonNull org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp timestamp) Takes an HL7 DTM-formatted value given as aHl7Dtm
, sets the resolution to the fraction of seconds by filling missing values to the end of the year, month, day, hour and minute if needed (i.e. sets it to the latest instant covered by the partial date). The DTM value must be given in UTC.By example, if the value "201903" is given, the day is fixed to the end of the month (the last of march) and the time is set to the end of the day (usually 23:59:59), which results in: "20190331235959".
If the HL7 DTM is already precise to the fraction of seconds, it will be returned as-is.
- Parameters:
timestamp
- The HL7 DTM-formatted dateTime to process.- Returns:
- the full precision dateTime.
-
toInstant
- Parameters:
timestamp
- The timestamp to convert.- Returns:
- the equivalent instant.
-
getZonedDateTime
@Deprecated(since="2024-08-23", forRemoval=true) public static @NonNull ZonedDateTime getZonedDateTime(@NonNull Instant instant) Deprecated, for removal: This API element is subject to removal in a future version.usegetZonedDateTime(Instant, ZoneId)
instead, to control the time zone.Converts anInstant
to a localZonedDateTime
.- Parameters:
instant
- The instant to convert.- Returns:
- the equivalent zoned date time.
-
getZonedDateTime
public static @NonNull ZonedDateTime getZonedDateTime(@NonNull Instant instant, @NonNull ZoneId zone) Converts anInstant
to aZonedDateTime
.- Parameters:
instant
- The instant to convert.zone
- The time zone to use.- Returns:
- the equivalent zoned date time.
-
toHl7Dtm
@Deprecated(since="2024-08-23", forRemoval=true) public static @NonNull String toHl7Dtm(@NonNull Instant instant) Deprecated, for removal: This API element is subject to removal in a future version.usetoHl7Dtm(Instant, ZoneId)
instead, to control the time zone.Formats anInstant
to an HL7 DTM. Local time zone is assumed.- Parameters:
instant
- The instant to convert.- Returns:
- the resulting HL7 DTM.
-
toHl7Dtm
Formats anInstant
to an HL7 DTM.- Parameters:
instant
- The instant to convert.zone
- The time zone to use.- Returns:
- the resulting HL7 DTM.
-
toDatetimeTs
@Deprecated(since="2024-08-23", forRemoval=true) public static @NonNull TS toDatetimeTs(@NonNull TemporalAccessor temporal) Deprecated, for removal: This API element is subject to removal in a future version.usetoDatetimeTs(TemporalAccessor, ZoneId)
instead, to control the time zone.- Parameters:
temporal
- The temporal object to convert.- Returns:
- the resulting timestamp.
-
toDatetimeTs
- Parameters:
temporal
- The temporal object to convert.zone
- The time zone to use.- Returns:
- the resulting timestamp.
-
toDateTs
@Deprecated(since="2024-08-23", forRemoval=true) public static @NonNull TS toDateTs(@NonNull TemporalAccessor temporal) Deprecated, for removal: This API element is subject to removal in a future version.usetoDateTs(TemporalAccessor, ZoneId)
instead, to control the time zone.- Parameters:
temporal
- The temporal object to convert.- Returns:
- the resulting timestamp.
-
toDateTs
Converts anInstant
to aTS
(TS.CH.TZ, Time Stamp) with a precision to the day with passed time zone.- Parameters:
temporal
- The temporal object to convert.zone
- time zone- Returns:
- the resulting timestamp.
-
toLocalDate
Converts aTS
(TS.CH.TZ, Time Stamp) to a local date. Only two formats are allowed in the TS.CH.TZ.- Parameters:
ts
- The timestamp to convert.- Returns:
- the equivalent local date or
null
if a null flavor was used in thets
.
-
getZonedDateTime(Instant, ZoneId)
instead, to control the time zone.