0

I'm sending a zoned date with Joda from Android to a backend service with ZonedDateTime but in backend the date is always "UTC".

The problem: I need to make an schedule agenda app that works in any country.

I send from my Android App a date with timezone. Ok, I'm doing this with Joda and Jackson, ex:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
private DateTime startDate;

Ok, it's sending

2018-04-16T16:41:38-0300

Until here I think it's everying ok.

In my backend service (Spring with Jackson) I'm using the ZonedDateTime:

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssZ")
private ZonedDateTime startDate;

And the result is always UTC :(

2018-04-16T19:41:38Z[UTC]
BodaoZ
  • 15
  • 7
  • 1
    Out of interest, how are you logging that last line of output? Perhaps something is converting it to UTC behind the scenes? (It's clearly managing to read the UTC offset.) As a somewhat separate note, knowing the UTC offset doesn't actually give you the time zone. If you want something to happen at (say "3pm every Tuesday, in London") then knowing that the offset *this* Tuesday is UTC+1 doesn't help you much. So you might want to consider sending the time zone ID entirely separately anyway. – Jon Skeet Apr 16 '18 at 20:11
  • I'm logging with Syso - System.out.println(body.getStartDate()). – BodaoZ Apr 16 '18 at 20:16
  • In backend I just changed from ZonedDateTime to LocalDateTime. And now I think it's working with zoned time. This don't make sense to my head.. o_O – BodaoZ Apr 16 '18 at 20:24

0 Answers0