Class TimestampHelper

java.lang.Object
de.digitalcollections.model.time.TimestampHelper

public class TimestampHelper extends Object
  • Constructor Details

    • TimestampHelper

      public TimestampHelper()
  • Method Details

    • truncatedToMicros

      public static LocalDateTime truncatedToMicros(LocalDateTime value)
      Truncate the time part of a LocalDateTime to microseconds.

      In Java 17 the resolution of time objects increased from microseconds to nanoseconds. Java always stored a time with nanosecond precision but the last three digits have been zero. With the increase of resolution we are facing trouble with the persistence layer: most databases only support microseconds, so does ours. As a consequence the original object and the one retrieved from the database are different -- they differ in 1000 nanoseconds. To overcome this inconsistency the time values must be truncated to microseconds, the resolution that the database can store.

      Parameters:
      value -
      Returns:
      the LocalDateTime truncated to microseconds