DateParser { public static Date parseW3CDateTime(String sDate, final Locale locale) { final int tIndex = sDate.indexOf("T"); if (tIndex > -1) { if (sDate.endsWith("Z")) { sDate = sDate.substring(0, sDate.length() - 1) + "+00:00"; } int tzdIndex = sDate.indexOf("+", tIndex); if (tzdIndex == -1) { tzdIndex = sDate.indexOf("-", tIndex); } if (tzdIndex > -1) { String pre = sDate.substring(0, tzdIndex); final int secFraction = pre.indexOf(","); if (secFraction > -1) { pre = pre.substring(0, secFraction); } final String post = sDate.substring(tzdIndex); sDate = pre + "GMT" + post; } } else { sDate += "T00:00GMT"; } return parseUsingMask(W3CDATETIME_MASKS, sDate, locale); } private  DateParser(); static Date parseRFC822(String sDate, final Locale locale); static Date parseW3CDateTime(String sDate, final Locale locale); static Date parseDate(final String sDate, final Locale locale); static String formatRFC822(final Date date, final Locale locale); static String formatW3CDateTime(final Date date, final Locale locale);  }
@Test public void parseW3CDateTimeIsOk() throws Exception { assertEquals( new Date(1000), DateParser.parseW3CDateTime("1970-01-01T00:00:01+00:00", Locale.GERMANY) ); }
@Test public void parseW3CDateTimeWithTrailingWhitespaceIsOk() throws Exception { assertEquals( new Date(1000), DateParser.parseW3CDateTime("1970-01-01T00:00:01+00:00 ", Locale.GERMANY) ); }