0

I got the time values from the SBT SDK as a string in this format

"2013-07-17T14:44:25.177Z"

I get a Java Date object with this code

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date date = dateFormat.parse("2013-07-17T14:44:25.177Z");

But the last part of the string ".177Z" should be a time zone value !?!?!

Do any body know how parse the time zone or the complete date with the time zone in Java?

Thx Andreas

2 Answers2

1

But the last part of the string ".177Z" should be a time zone value !?!?!

No, I think the .177 is the milliseconds part, and Z is a UTC-offset of 0. (It's not really a time zone, but that's a different matter.)

I suspect you want:

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");

(Where X is an ISO-8601 time zone specifier, including Z for UTC.)

Note that X was only introduced in Java 7 - if you're using Java 6 or earlier, you may need to do a bit more work.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thx Jon. At the Domino server runs an older Java version :-( I ignore the UTC-offset in the moment. – Andreas Nebel Jul 29 '13 at 09:02
  • @AndreasNebel: If you can use Joda Time instead, that might support what you need. Is the offset *always* Z, or is it sometimes non-zero values? – Jon Skeet Jul 29 '13 at 09:52
  • @Jon: I worked on a standard CRM product. Therefore I need a generic solution. But on this place I can ignore the UTC-off set. Thx Jon – Andreas Nebel Jul 30 '13 at 12:34
0

You might want to use

javax.xml.bind.DatatypeConverter.parseTime(String)

since the dates found in the atom returned by the IBM Connections API conform to the definition from http://www.w3.org/TR/xmlschema-2/, which can be parsed into a Java Calendar Object by said method. This also accounts for the time zone specifier.

BennyLau
  • 107
  • 8