1

quarkus jsonb is deserializing json in UTC. How can I configure a different timezone?

public class AtendimentoDTO {
    public Integer id;

    @JsonbDateFormat("dd/MM/yyyy HH:mm:ss")
    private Date dataAtualizacao;
}

Output in UTC:

"dataAtualizacao": "23/05/2020 21:55:57"

maven dependency:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
user4081947
  • 141
  • 1
  • 7

3 Answers3

2

I was able to fix it by changing the provider to jackson and using:

@JsonFormat(shape = JsonFormat.Shape.STRING, 
  pattern = "dd/MM/yyyy HH:mm:ss", timezone = "GMT-3")    
fjsv
  • 705
  • 10
  • 23
user4081947
  • 141
  • 1
  • 7
1

Try this date format:

@JsonbDateFormat("dd/MM/yyyy HH:mm:ss Z")

And afaik, LocalDateTime doesn't support timezones. You need to use ZonedDateTime but I am not sure whether this works out-of-the-box with JsonB, otherwise you need to write a Serializer & Deserializer for it.

Serkan
  • 639
  • 5
  • 14
0

You can use LocalDateTime instead of Date. LocalDateTime will take the default system time-zone, while Date will be using UTC timezone by default.

iabughosh
  • 481
  • 5
  • 19