From 85eccff05dc687bab86363aa40b61b0d6ed9f6be Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 12 Oct 2003 03:22:41 +0000 Subject: Also parse US dates for yyyy-MM-dd hh:mm:ss. Use HH instead of hh for 24 hour time format --- src/org/noreply/fancydress/misc/Util.java | 18 +++++++++++++----- 1 file 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 s * @throws ParseException if s 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 s * @throws ParseException if s 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 { -- cgit v1.2.3