FasterXML / FasterXML/jackson-modules-java8

Instants get not deserialized as expected sometimes (millis vs nanos, non-fractional numbers)

Aberta
#304 3 comentários 0 reações 0 responsáveis Ver no GitHub
test-needed
Linguagem predominante
Java
Estrelas
425
Forks
124
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hey guys,

I bumped into this issue and it took me some time to figure out what was wrong on my side.
Maybe you don't even consider this as an issue but let me explain first what happened on my side.

When having the flag disabled for WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS

It will eventually write timestamps in Milliseconds:
`1709296652087`

When I now missed the flag READ_DATE_TIMESTAMPS_AS_NANOSECONDS

and read this we will get an insane Instant consisting of:
Seconds `1709296652087`
and
Nanos `0`

Using any site online it would understand and consider it as a Milliseconds timestamp.

I guess usually you would just split up a timestamp with a dot and put it to Seconds and Nanos, but I think theoretically both should be possible.

So do you think we could have a feature where we parse values based on their length?
11 characters or less = Seconds
12 to 15 characters = Millis
16 to 18 characters = Micros
19 to 21 characters = Nanos

While writing I am realizing that this might feel less consistent but I also think this might be an interesting flag to add,
you be the judge.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Comece localizando o tratamento de READ_DATE_TIMESTAMPS_AS_NANOSECONDS e WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS e, em seguida, reproduza a desserialização do valor em milissegundos 1709296652087. Revise como timestamps inteiros são diferenciados de valores fracionários e defina o comportamento desejado para segundos, milissegundos, micros e nanos antes de implementar ou testar a opção proposta.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
java
Domínio
backend
Tipo de issue
Funcionalidade
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.