Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parsing timestamp with timezone having offset of format +hh:mm:ss #509

Closed
khlopkov opened this issue May 5, 2022 · 0 comments
Closed
Labels
type: enhancement A general enhancement

Comments

@khlopkov
Copy link

khlopkov commented May 5, 2022

Feature Request

Is your feature request related to a problem? Please describe

tested on postgres:10-alpine docker image

I have an issue when trying to parse timestamp with timezone in format of 0001-01-01 08:20:53+02:30:17 to LocalDateTime/OffsetDateTime/ZonedDateTime. Here is an example test code on groovy:

def temp() {
        Function<Row, OffsetDateTime> fn = note -> note.get("datetime", OffsetDateTime)

        expect:
        def datetime = databaseClient.sql("SELECT '0001-01-01 08:20:53+02:30:17'::timestamptz as datetime")
            .map(fn).first()
            .block()
    }

which giving following stacktrace:

Text '0001-01-01 08:20:53+02:30:17' could not be parsed, unparsed text found at index 25
java.time.format.DateTimeParseException: Text '0001-01-01 08:20:53+02:30:17' could not be parsed, unparsed text found at index 25
	at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2055)
	at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1954)
	at io.r2dbc.postgresql.codec.AbstractTemporalCodec.decodeTemporal(AbstractTemporalCodec.java:135)
	at io.r2dbc.postgresql.codec.AbstractTemporalCodec.decodeTemporal(AbstractTemporalCodec.java:95)

Describe the solution you'd like

it seems that for year which is lower then 1920 postgres does not convert timestamp with timezone to format of +hh:00:00 and leaves it in unformatted way (e. g. +02:30:17).
This could be fixed by adding following change to PostgresqlDateTimeFormatter

-            .appendOffset("+HH:mm", "+00:00")
+            .appendOffset("+HH:mm:ss", "+00:00:00")

Describe alternatives you've considered

Conversion of offset could be fixed in postgresql which will take more time, I suppose

Teachability, Documentation, Adoption, Migration Strategy

Nothing to document

@khlopkov khlopkov added the type: enhancement A general enhancement label May 5, 2022
khlopkov pushed a commit to khlopkov/r2dbc-postgresql that referenced this issue May 5, 2022
@mp911de mp911de changed the title Issue parsing timestamp with timezone having offset of format '+hh:mm:ss' Issue parsing timestamp with timezone having offset of format +hh:mm:ss May 17, 2022
@mp911de mp911de modified the milestones: 1.0.0.RELEASE, 0.8.13.RELEASE May 17, 2022
mp911de added a commit that referenced this issue May 17, 2022
Add support for offset representation variants (short and full).

[#509][resolves #510]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
mp911de pushed a commit that referenced this issue May 17, 2022
mp911de added a commit that referenced this issue May 17, 2022
Add support for offset representation variants (short and full).

[#509][resolves #510]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
mp911de pushed a commit that referenced this issue May 17, 2022
mp911de added a commit that referenced this issue May 17, 2022
Add support for offset representation variants (short and full).

[#509][resolves #510]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants