Menu

#331 java.time.* support

closed-accepted
jdbc (34)
1
2017-02-11
2016-10-03
No

My understanding is that the guidance for implementing in JDBC 4.2 the new Java 8 java.time classes, is to use the to/fromObject() methods of RecordSet and then cast explicitly. See for example on stackoverflow.

I would suggest the use of the following mappings:

SQL type java.time type
TIME LocalTime
TIME WITH TIME ZONE OffsetTime
TIMESTAMP LocalDate
TIMESTAMP WITH TIME ZONE OffsetDateTime

On a separate note, you may want to re-consider the toString() representation of sql timestamps - currently HSQL uses a rather unique representation where the hour and offset-hour are not padded with zeros. I don't have access to the SQL spec but I suspect that this is not a format used by ISO or any RFC, so I would guess not by SQL either. The reason this is a little relevant here is because the Java8 formatters are unable to parse/print such timestamps (specifically the offset-hour without a leading zero). I found this out as I was looking at the implementation in the typesafe slick ORM, where they're currently using the toString() representation to add Java8 support in the short-term.

Discussion

  • Luciano Joublanc

    Sorry, should have been:

    SQL type java.time type
    TIME LocalTime
    TIME WITH TIME ZONE OffsetTime
    TIMESTAMP LocalDateTime
    TIMESTAMP WITH TIME ZONE OffsetDateTime
    DATE LocalDate
    INSTANT Instant ?
     
  • Fred Toussi

    Fred Toussi - 2017-02-11
    • status: open --> closed-accepted
    • assigned_to: Fred Toussi
    • Priority: 5 --> 1
     
  • Fred Toussi

    Fred Toussi - 2017-02-11

    supported in version 2.4.0

     

Log in to post a comment.

MongoDB Logo MongoDB