@Test public void testParserOnTimeInstantFormat27() throws ParseException { final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); df.setTimeZone(TimeZone.getTimeZone("GMT")); String timeInstant = "20111010T10:11:20.666"; Collection time = PARSER.parse(timeInstant); assertEquals(1, time.size()); assertEquals("2011-10-10T10:11:20.666Z", df.format(getTime(time, 0))); }
@SuppressWarnings({"unchecked", "rawtypes"}) public Collection parse(String value) throws ParseException { if (value == null) { return Collections.emptyList(); } value = value.trim(); if (value.length() == 0) { return Collections.emptyList(); } final Set result = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { final boolean o1Date = o1 instanceof Date; final boolean o2Date = o2 instanceof Date; if (o1 == o2) { return 0; } if (o1Date) { final Date dateLeft = (Date) o1; if (o2Date) { return dateLeft.compareTo((Date) o2); } return dateLeft.compareTo(((DateRange) o2).getMinValue()); } final DateRange left = (DateRange) o1; if (o2Date) { return left.getMinValue().compareTo(((Date) o2)); } return left.getMinValue().compareTo(((DateRange) o2).getMinValue()); } }); String[] listDates = value.split(","); int maxValues = maxTimes; for (String date : listDates) { if (date.indexOf("/") <= 0) { Object o = getFuzzyDate(date); if (o instanceof Date) { addDate(result, (Date) o); } else { addPeriod(result, (DateRange) o); } } else { String[] period = date.split("/"); if (period.length == 3) { Date[] range = parseTimeDuration(period); final long millisIncrement = parsePeriod(period[2]); final long startTime = range[0].getTime(); final long endTime = range[1].getTime(); long time; int j = 0; while ((time = j * millisIncrement + startTime) <= endTime) { final Calendar calendar = new GregorianCalendar(UTC_TZ); calendar.setTimeInMillis(time); addDate(result, calendar.getTime()); j++; checkMaxTimes(result, maxValues); } } else if (period.length == 2) { Date[] range = parseTimeDuration(period); addPeriod(result, new DateRange(range[0], range[1])); } else { throw new ParseException("Invalid time period: " + Arrays.toString(period), 0); } } checkMaxTimes(result, maxValues); } return new ArrayList(result); }
DateTimeParser { @SuppressWarnings({"unchecked", "rawtypes"}) public Collection parse(String value) throws ParseException { if (value == null) { return Collections.emptyList(); } value = value.trim(); if (value.length() == 0) { return Collections.emptyList(); } final Set result = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { final boolean o1Date = o1 instanceof Date; final boolean o2Date = o2 instanceof Date; if (o1 == o2) { return 0; } if (o1Date) { final Date dateLeft = (Date) o1; if (o2Date) { return dateLeft.compareTo((Date) o2); } return dateLeft.compareTo(((DateRange) o2).getMinValue()); } final DateRange left = (DateRange) o1; if (o2Date) { return left.getMinValue().compareTo(((Date) o2)); } return left.getMinValue().compareTo(((DateRange) o2).getMinValue()); } }); String[] listDates = value.split(","); int maxValues = maxTimes; for (String date : listDates) { if (date.indexOf("/") <= 0) { Object o = getFuzzyDate(date); if (o instanceof Date) { addDate(result, (Date) o); } else { addPeriod(result, (DateRange) o); } } else { String[] period = date.split("/"); if (period.length == 3) { Date[] range = parseTimeDuration(period); final long millisIncrement = parsePeriod(period[2]); final long startTime = range[0].getTime(); final long endTime = range[1].getTime(); long time; int j = 0; while ((time = j * millisIncrement + startTime) <= endTime) { final Calendar calendar = new GregorianCalendar(UTC_TZ); calendar.setTimeInMillis(time); addDate(result, calendar.getTime()); j++; checkMaxTimes(result, maxValues); } } else if (period.length == 2) { Date[] range = parseTimeDuration(period); addPeriod(result, new DateRange(range[0], range[1])); } else { throw new ParseException("Invalid time period: " + Arrays.toString(period), 0); } } checkMaxTimes(result, maxValues); } return new ArrayList(result); } }
DateTimeParser { @SuppressWarnings({"unchecked", "rawtypes"}) public Collection parse(String value) throws ParseException { if (value == null) { return Collections.emptyList(); } value = value.trim(); if (value.length() == 0) { return Collections.emptyList(); } final Set result = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { final boolean o1Date = o1 instanceof Date; final boolean o2Date = o2 instanceof Date; if (o1 == o2) { return 0; } if (o1Date) { final Date dateLeft = (Date) o1; if (o2Date) { return dateLeft.compareTo((Date) o2); } return dateLeft.compareTo(((DateRange) o2).getMinValue()); } final DateRange left = (DateRange) o1; if (o2Date) { return left.getMinValue().compareTo(((Date) o2)); } return left.getMinValue().compareTo(((DateRange) o2).getMinValue()); } }); String[] listDates = value.split(","); int maxValues = maxTimes; for (String date : listDates) { if (date.indexOf("/") <= 0) { Object o = getFuzzyDate(date); if (o instanceof Date) { addDate(result, (Date) o); } else { addPeriod(result, (DateRange) o); } } else { String[] period = date.split("/"); if (period.length == 3) { Date[] range = parseTimeDuration(period); final long millisIncrement = parsePeriod(period[2]); final long startTime = range[0].getTime(); final long endTime = range[1].getTime(); long time; int j = 0; while ((time = j * millisIncrement + startTime) <= endTime) { final Calendar calendar = new GregorianCalendar(UTC_TZ); calendar.setTimeInMillis(time); addDate(result, calendar.getTime()); j++; checkMaxTimes(result, maxValues); } } else if (period.length == 2) { Date[] range = parseTimeDuration(period); addPeriod(result, new DateRange(range[0], range[1])); } else { throw new ParseException("Invalid time period: " + Arrays.toString(period), 0); } } checkMaxTimes(result, maxValues); } return new ArrayList(result); } DateTimeParser();  DateTimeParser(int maxTimes);  DateTimeParser(int maxTimes, int flags); }
DateTimeParser { @SuppressWarnings({"unchecked", "rawtypes"}) public Collection parse(String value) throws ParseException { if (value == null) { return Collections.emptyList(); } value = value.trim(); if (value.length() == 0) { return Collections.emptyList(); } final Set result = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { final boolean o1Date = o1 instanceof Date; final boolean o2Date = o2 instanceof Date; if (o1 == o2) { return 0; } if (o1Date) { final Date dateLeft = (Date) o1; if (o2Date) { return dateLeft.compareTo((Date) o2); } return dateLeft.compareTo(((DateRange) o2).getMinValue()); } final DateRange left = (DateRange) o1; if (o2Date) { return left.getMinValue().compareTo(((Date) o2)); } return left.getMinValue().compareTo(((DateRange) o2).getMinValue()); } }); String[] listDates = value.split(","); int maxValues = maxTimes; for (String date : listDates) { if (date.indexOf("/") <= 0) { Object o = getFuzzyDate(date); if (o instanceof Date) { addDate(result, (Date) o); } else { addPeriod(result, (DateRange) o); } } else { String[] period = date.split("/"); if (period.length == 3) { Date[] range = parseTimeDuration(period); final long millisIncrement = parsePeriod(period[2]); final long startTime = range[0].getTime(); final long endTime = range[1].getTime(); long time; int j = 0; while ((time = j * millisIncrement + startTime) <= endTime) { final Calendar calendar = new GregorianCalendar(UTC_TZ); calendar.setTimeInMillis(time); addDate(result, calendar.getTime()); j++; checkMaxTimes(result, maxValues); } } else if (period.length == 2) { Date[] range = parseTimeDuration(period); addPeriod(result, new DateRange(range[0], range[1])); } else { throw new ParseException("Invalid time period: " + Arrays.toString(period), 0); } } checkMaxTimes(result, maxValues); } return new ArrayList(result); } DateTimeParser();  DateTimeParser(int maxTimes);  DateTimeParser(int maxTimes, int flags); @SuppressWarnings({"unchecked", "rawtypes"}) Collection parse(String value); void checkMaxTimes(Set result, int maxValues); static long parsePeriod(final String period); }
DateTimeParser { @SuppressWarnings({"unchecked", "rawtypes"}) public Collection parse(String value) throws ParseException { if (value == null) { return Collections.emptyList(); } value = value.trim(); if (value.length() == 0) { return Collections.emptyList(); } final Set result = new TreeSet( new Comparator() { public int compare(Object o1, Object o2) { final boolean o1Date = o1 instanceof Date; final boolean o2Date = o2 instanceof Date; if (o1 == o2) { return 0; } if (o1Date) { final Date dateLeft = (Date) o1; if (o2Date) { return dateLeft.compareTo((Date) o2); } return dateLeft.compareTo(((DateRange) o2).getMinValue()); } final DateRange left = (DateRange) o1; if (o2Date) { return left.getMinValue().compareTo(((Date) o2)); } return left.getMinValue().compareTo(((DateRange) o2).getMinValue()); } }); String[] listDates = value.split(","); int maxValues = maxTimes; for (String date : listDates) { if (date.indexOf("/") <= 0) { Object o = getFuzzyDate(date); if (o instanceof Date) { addDate(result, (Date) o); } else { addPeriod(result, (DateRange) o); } } else { String[] period = date.split("/"); if (period.length == 3) { Date[] range = parseTimeDuration(period); final long millisIncrement = parsePeriod(period[2]); final long startTime = range[0].getTime(); final long endTime = range[1].getTime(); long time; int j = 0; while ((time = j * millisIncrement + startTime) <= endTime) { final Calendar calendar = new GregorianCalendar(UTC_TZ); calendar.setTimeInMillis(time); addDate(result, calendar.getTime()); j++; checkMaxTimes(result, maxValues); } } else if (period.length == 2) { Date[] range = parseTimeDuration(period); addPeriod(result, new DateRange(range[0], range[1])); } else { throw new ParseException("Invalid time period: " + Arrays.toString(period), 0); } } checkMaxTimes(result, maxValues); } return new ArrayList(result); } DateTimeParser();  DateTimeParser(int maxTimes);  DateTimeParser(int maxTimes, int flags); @SuppressWarnings({"unchecked", "rawtypes"}) Collection parse(String value); void checkMaxTimes(Set result, int maxValues); static long parsePeriod(final String period); static final int FLAG_GET_TIME_ON_PRESENT; static final int FLAG_GET_TIME_ON_NOW; static final int FLAG_GET_TIME_ON_CURRENT; static final int FLAG_IS_LENIENT; static final int FLAG_SINGLE_DATE_AS_DATERANGE; static final String[] LENIENT_FORMATS_MILLISECOND; static final String[] LENIENT_FORMATS_SECOND; static final String[] LENIENT_FORMATS_MINUTE; static final String[] LENIENT_FORMATS_HOUR; static final String[] LENIENT_FORMATS_DAY; static final String[] LENIENT_FORMATS_MONTH; static final String[] LENIENT_FORMATS_YEAR; static final TimeZone UTC_TZ; static final long MILLIS_IN_DAY; }