¿Cómo convertir la marca de tiempo de PostgreSQL con zona horaria a Java Instant o OffSetDateTime?
Marca de tiempo de PostgreSQL con formato de zona horaria: 2020-06-18 16:15:38+05:30
Obtener la siguiente excepción en Java 11.7 - Ubuntu para Instant.parse("2020-06-18 16:15:38+05:30".replace(" ", "T"))
Exception in thread "main" java.time.format.DateTimeParseException: Text '2020-06-18T16:15:38+05:30' could not be parsed at index 19 at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2046) at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948) at java.base/java.time.Instant.parse(Instant.java:395) at OffSetDateTimeExample.main(OffSetDateTimeExample.java:9)pero funciona en Java 13.
Cualquier ayuda para que funcione en Java 11
tstzrange es un tipo de rango en Postgres.
Divida el tstzrange de PostgreSQL en la consulta llamando a las funciones lower y upper .
select *, lower(tstzrange) as lower_tstzrange, upper(tstzrange) as upper_tstzrange from announcement ; y utilícelo en Resultset como OffsetDateTime
TstzRange.builder() .startDateTime(rs.getObject("lower_tstzrange", OffsetDateTime.class)) .endDateTime(rs.getObject("upper_tstzrange", OffsetDateTime.class)) .build()Gracias a a_horse_with_no_name y Arvind Kumar Avinash por salvarme el día y aprender a dividir tipos de datos de rango.