-2

I got a date 2014-01-01T01:14:48.000+08:00 from a web server. Does anyone know how to parse this correctly? How to get its time offset?

liminche
  • 261
  • 1
  • 6
  • 13

2 Answers2

1
String s="2014-01-01T01:14:48.000+08:00";
         SimpleDateFormat sdf=new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
         System.out.println(sdf.format(s));
Chandu D
  • 505
  • 3
  • 17
0

You need something like this,

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSX");
System.out.println(sdf.parse(y));

The X is for timezone.

Codebender
  • 14,221
  • 7
  • 48
  • 85