summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-10-12 03:22:41 +0000
committerPeter Palfrader <peter@palfrader.org>2003-10-12 03:22:41 +0000
commit85eccff05dc687bab86363aa40b61b0d6ed9f6be (patch)
tree68f5b8ebb143e1cbdea8caa3bbc7e18d394fe9ca
parentae2f9c5150c7871d7e86b162a96c48750afc9bb6 (diff)
Also parse US dates for yyyy-MM-dd hh:mm:ss.
Use HH instead of hh for 24 hour time format
-rw-r--r--src/org/noreply/fancydress/misc/Util.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/org/noreply/fancydress/misc/Util.java b/src/org/noreply/fancydress/misc/Util.java
index f9962bf..a111b88 100644
--- a/src/org/noreply/fancydress/misc/Util.java
+++ b/src/org/noreply/fancydress/misc/Util.java
@@ -177,31 +177,39 @@ public class Util {
}
}
/**
- * Parse an ISO date yyyy-MM-dd hh:mm:ss.
+ * Parse an ISO date yyyy-MM-dd HH:mm:ss.
*
* @param s a string holding a date
* @return Date the date represented in <code>s</code>
* @throws ParseException if <code>s</code> is not a valid date of that format
*/
public static Date parseDateTime(String s) {
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
format.setLenient(false);
try {
return format.parse(s);
} catch (ParseException e) {
- return null;
+ /* FIXME: US date.. */
+ format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ format.setLenient(false);
+ try {
+ return format.parse(s);
+ } catch (ParseException e2) {
+ return null;
+ }
}
}
/**
- * Parse an ISO date yyyy-MM-dd hh:mm:ss.SSSS.
+ * Parse an ISO date yyyy-MM-dd HH:mm:ss.SSSS.
*
* @param s a string holding a date
* @return Date the date represented in <code>s</code>
* @throws ParseException if <code>s</code> is not a valid date of that format
*/
public static Date parseDateTimeMS(String s) {
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSS");
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSS");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
format.setLenient(false);
try {