Permalink
Browse files

Timestamps are encoded differently in newer versions of vCD

  • Loading branch information...
1 parent 113490d commit d508b7a62f62b7dba1655f878b0092f732977304 @rgerganov rgerganov committed Aug 30, 2013
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/main/java/com/vmware/vcloud/nclient/NotificationMessage.java
@@ -121,8 +121,14 @@ static NotificationMessage createFromJson(String payload, Map<String, Object> he
result.success = (Boolean) data.get(JSON_KEY_STATUS);
}
if (data.containsKey(JSON_KEY_TIMESTAMP)) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- result.timestamp = sdf.parse((String) data.get(JSON_KEY_TIMESTAMP));
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ result.timestamp = sdf.parse((String) data.get(JSON_KEY_TIMESTAMP));
+ } catch (java.text.ParseException ex) {
+ String date = (String) data.get(JSON_KEY_TIMESTAMP);
+ XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(date);
+ result.timestamp = xmlDate.toGregorianCalendar().getTime();
+ }
}
return result;
}

0 comments on commit d508b7a

Please sign in to comment.