-1

I get from the server is like 2017-01-24T16:16:30.690Z.

This date is in GMT time zone.

I want to convert this time into GMT+6 time zone as well as time format.

My expected result is: 24 January 2017 22:16

Mahbub Mukul
  • 333
  • 3
  • 18
  • 2
    So it sounds like you should be using a `SimpleDateFormat` with an appropriate format and time zone... have you tried anything yet? What happened? – Jon Skeet Jan 24 '17 at 17:21

1 Answers1

1

See above comments. If you apply those, try:

    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
    Date date = sdf.parse("2017-01-24T16:16:30.690Z", new ParsePosition(0));
    sdf.setTimeZone(TimeZone.getTimeZone("GMT+06:00"));
    sdf.applyPattern("d MMMM yyyy HH:mm");
    String formatted = sdf.format(date);

Worked for me.

Martin G
  • 229
  • 1
  • 6