Class Datetime.Time.AsLocalTime

java.lang.Object
org.postgresql.pljava.adt.Datetime.Time.AsLocalTime
All Implemented Interfaces:
Adapter.Contract<LocalTime>, Adapter.Contract.Scalar<LocalTime>, Datetime.Time<LocalTime>
Enclosing interface:
Datetime.Time<T>

public static class Datetime.Time.AsLocalTime extends Object implements Datetime.Time<LocalTime>
A reference implementation that maps to LocalTime.

While PostgreSQL allows 24:00:00 as a valid time, LocalTime maxes out at the preceding nanosecond. That is still a value that can be distinguished, because PostgreSQL's time resolution is only to microseconds, so the PostgreSQL 24:00:00 value will be mapped to that.

In the other direction, nanoseconds will be rounded to microseconds, so any value within the half-microsecond preceding HOUR24 will become the PostgreSQL 24:00:00 value.

  • Field Details

    • INSTANCE

      public static final Datetime.Time.AsLocalTime INSTANCE
    • HOUR24

      public static final LocalTime HOUR24
      LocalTime representing the 24:00:00 time that PostgreSQL accepts but LocalTime does not.

      This LocalTime represents the immediately preceding nanosecond. That is still distinguishable from any other PostgreSQL time, because those have only microsecond resolution.

  • Method Details

    • construct

      public LocalTime construct(long microsecondsSinceMidnight)
      Description copied from interface: Datetime.Time
      Constructs a representation T from the components of the PostgreSQL data type.

      The argument represents microseconds since midnight, nonnegative and not exceeding USECS_PER_DAY.

      PostgreSQL does allow the value to exactly equal USECS_PER_DAY. 24:00:00 is considered a valid value. That may need extra attention if the representation to be constructed doesn't allow that.

      Specified by:
      construct in interface Datetime.Time<LocalTime>
    • store

      public <T> T store(LocalTime t, Datetime.Time<T> f)