-8

I have a date in string, provide by webservices:

2013-05-13T10:06:34.023-03:00

How to parse this to Java Date?

SimpleDateFormat with yyyy-MM-dd HH:mm doesn't work...

I need only date and time (not -3:00).

Thanks, Mateus

Adrien Lacroix
  • 3,502
  • 1
  • 20
  • 23
Mateus
  • 389
  • 3
  • 20

2 Answers2

2

yyyy-MM-dd HH:mm does not work because it does not match your example.

What about "yyyy-MM-dd'T'HH:mm:ss.SSSZ"?

I took this pattern from JavaDoc of SimpleDateFormat: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

AlexR
  • 114,158
  • 16
  • 130
  • 208
2

You need to use:

yyyy-MM-dd'T'HH:mm:ss.SSSZ as per the JavaDoc for SimpleDateFormat.

I would also suggest you do need the -3:00 - this is the timezone the time applies to and says the time is UTC -3 hours.

Nick Holt
  • 33,455
  • 4
  • 52
  • 58