private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
private String adjustTz(String toParse) { String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; return toParse.replace("UTC", ""); }
@Override public final Date iso8601SecondsDateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SecondsSimpleDateFormat) { try { return iso8601SecondsSimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601SecondsDateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SecondsSimpleDateFormat) { try { return iso8601SecondsSimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601SecondsDateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SecondsSimpleDateFormat) { try { return iso8601SecondsSimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601DateParse(String toParse) { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SimpleDateFormat) { try { return iso8601SimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Override public final Date iso8601SecondsDateParse(String toParse) throws IllegalArgumentException { if (toParse.length() < 10) throw new IllegalArgumentException("incorrect date format " + toParse); String tz = findTZ(toParse); toParse = trimToMillis(toParse); toParse = trimTZ(toParse); toParse += tz; if (toParse.charAt(10) == ' ') toParse = new StringBuilder(toParse).replace(10, 11, "T").toString(); synchronized (iso8601SecondsSimpleDateFormat) { try { return iso8601SecondsSimpleDateFormat.parse(toParse); } catch (ParseException pe) { throw new IllegalArgumentException("Error parsing data at " + pe.getErrorOffset(), pe); } } }
@Test public void testTrimsToMillisWithTimezone() { assertEquals("NO_MILLISZ", DateUtils.trimToMillis("NO_MILLISZ")); assertEquals("NO_MILLIS.1Z", DateUtils.trimToMillis("NO_MILLIS.1Z")); assertEquals("NO_MILLIS.12Z", DateUtils.trimToMillis("NO_MILLIS.12Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123456Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234567Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345689Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345690123345678Z")); }
@Test public void testTrimsToMillisNoTimezone() { assertEquals("NO_MILLIS", DateUtils.trimToMillis("NO_MILLIS")); assertEquals("NO_MILLIS.1", DateUtils.trimToMillis("NO_MILLIS.1")); assertEquals("NO_MILLIS.12", DateUtils.trimToMillis("NO_MILLIS.12")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123456")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234567")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345689")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345690123345678")); } }
@Test public void testTrimsToMillisWithTimezone() { assertEquals("NO_MILLISZ", DateUtils.trimToMillis("NO_MILLISZ")); assertEquals("NO_MILLIS.1Z", DateUtils.trimToMillis("NO_MILLIS.1Z")); assertEquals("NO_MILLIS.12Z", DateUtils.trimToMillis("NO_MILLIS.12Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123456Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234567Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345689Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345690123345678Z")); }
@Test public void testTrimsToMillisNoTimezone() { assertEquals("NO_MILLIS", DateUtils.trimToMillis("NO_MILLIS")); assertEquals("NO_MILLIS.1", DateUtils.trimToMillis("NO_MILLIS.1")); assertEquals("NO_MILLIS.12", DateUtils.trimToMillis("NO_MILLIS.12")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123456")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234567")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345689")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345690123345678")); } }