diff --git a/splunk/com/splunk/Resource.java b/splunk/com/splunk/Resource.java index 8d8ecc42..4dc43e27 100644 --- a/splunk/com/splunk/Resource.java +++ b/splunk/com/splunk/Resource.java @@ -16,7 +16,7 @@ package com.splunk; - +import java.util.Date; import java.util.Map; /** @@ -35,6 +35,7 @@ public abstract class Resource { /* Initialized by {@link #load()}. */ protected Map actions; protected String title; + protected Date updated; private boolean maybeValid = false; /** @@ -128,6 +129,16 @@ public String getTitle() { return validate().title; } + /** + * Return the last updated time of this resource, which corresponds to the Atom + * {@code } element. + * + * @return The resource last updated time. + */ + public Date getUpdated() { + return validate().updated; + } + /** * Marks the local state of this resource as no longer current. * @@ -152,6 +163,7 @@ Resource load(AtomObject value) { else { this.actions = value.links; this.title = value.title; + this.updated = Value.toDate(value.updated); } this.maybeValid = true; return this; diff --git a/splunk/com/splunk/Value.java b/splunk/com/splunk/Value.java index 9c7694ce..f71c7cdd 100644 --- a/splunk/com/splunk/Value.java +++ b/splunk/com/splunk/Value.java @@ -82,7 +82,7 @@ else if (value.endsWith("GB")) */ static Date toDate(String value) { if (dateFormat == null) { - dateFormat = new SimpleDateFormat[4]; + dateFormat = new SimpleDateFormat[6]; dateFormat[0] = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); dateFormat[0].setLenient(true); dateFormat[1] = new SimpleDateFormat("E MMM d HH:mm:ss z y"); @@ -91,6 +91,10 @@ static Date toDate(String value) { dateFormat[2].setLenient(true); dateFormat[3] = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); dateFormat[3].setLenient(true); + dateFormat[4] = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + dateFormat[4].setLenient(true); + dateFormat[5] = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + dateFormat[5].setLenient(true); } if (datePattern == null) { String pattern = "(.*)\\.\\d+([\\-+]\\d+):(\\d+)"; @@ -98,9 +102,6 @@ static Date toDate(String value) { } for (SimpleDateFormat simpleDateFormat: dateFormat) { - // Must first remove the colon (':') from the timezone - // field, or SimpleDataFormat will not parse correctly. - // Eg: 2010-01-01T12:00:00+01:00 => 2010-01-01T12:00:00+0100 try { Matcher matcher = datePattern.matcher(value);