0

I have problems with formatting server time. Server is on central time I guess. I need to format following string 2016-08-22T10:29:22 in default zone (Central European Summer Time = GMT+2). I tried with Joda-Time library, I need to get 12:29:22, but I only managed to get same date with +02:00 the end, with code like this:

 DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss");
        DateTime dateTime = formatter.withZone(DateTimeZone.getDefault()).parseDateTime(time);

Output of this code is: 2016-08-22T10:29:22.000+02:00, when I try to dateTime.getHourOfDay(); - I getting 10 again.

Where am I going wrong?

Sasaman
  • 272
  • 1
  • 9

1 Answers1

0

2016-08-22T10:29:22 in default zone (Central European Summer Time = GMT+2).

10:29 in GMT+2 is 10:29 in GMT+2 and 8:29 in GMT, and the 2016-08-22T10:29:22 simply lacks information of timezone. So either make server return timezone or manually add it (i.e. append Z) prior converting.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • You didn't get me, I need to format date 2016-08-22T10:29:22 in date in default time zone(mine is Central European Summer Time = GMT+2). I got it now, can you help me with formatting manually and adding timezone? – Sasaman Aug 22 '16 at 11:51
  • [convert one time zone to another using joda time](http://stackoverflow.com/q/21258214/1235698) – Marcin Orlowski Aug 22 '16 at 12:01
  • Done! Thank you. :) – Sasaman Aug 22 '16 at 12:32