Class DateTimes
- Author:
- Quentin Ligier
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull Hl7DtmcompleteToEarliestInstant(@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 Hl7DtmcompleteToEarliestInstant(@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 Hl7DtmcompleteToLatestInstant(@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 Hl7DtmcompleteToLatestInstant(@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 ZonedDateTimegetZonedDateTime(@NonNull Instant instant) Deprecated, for removal: This API element is subject to removal in a future version.static @NonNull ZonedDateTimegetZonedDateTime(@NonNull Instant instant, @NonNull ZoneId zone) Converts anInstantto aZonedDateTime.static @NonNull TStoDatetimeTs(@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 TStoDatetimeTs(@NonNull TemporalAccessor temporal, @NonNull ZoneId zone) static @NonNull TStoDateTs(@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 TStoDateTs(@NonNull TemporalAccessor temporal, ZoneId zone) static @NonNull StringDeprecated, for removal: This API element is subject to removal in a future version.usetoHl7Dtm(Instant, ZoneId)instead, to control the time zone.static @NonNull StringFormats anInstantto an HL7 DTM.static @NonNull Instantstatic @Nullable LocalDatetoLocalDate(@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 anInstantto 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 anInstantto 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 anInstantto an HL7 DTM. Local time zone is assumed.- Parameters:
instant- The instant to convert.- Returns:
- the resulting HL7 DTM.
-
toHl7Dtm
Formats anInstantto 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 anInstantto 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
nullif a null flavor was used in thets.
-
getZonedDateTime(Instant, ZoneId)instead, to control the time zone.