List of utility methods to do Date ISO Parse
Date | parseISODate(String date) Returns a date parsed from a date/dateTime string formatted accorings to ISO 8601 rules. String pattern; StringBuffer buffer = new StringBuffer(date); switch (buffer.length()) { case 4: pattern = "yyyy"; break; case 7: pattern = "yyyy-MM"; ... |
Date | parseIsoDate(String str) Converts an ISO date or datetime string to a date object. Date date; try { date = ISO_DATETIME_FORMAT.parse(str); if (formatIsoDateTime(date).equals(str)) { return date; } catch (ParseException e) { try { date = ISO_DATE_FORMAT.parse(str); if (formatIsoDate(date).equals(str)) { return date; } catch (ParseException e) { return null; |
Date | parseIsoDate2(String s) parse Iso Date SimpleDateFormat iso8601format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); try { return iso8601format.parse(s); } catch (Exception e) { return null; |
Calendar | parseIsoDateAndTimeString(String aDateString, String aTimeString) parse Iso Date And Time String String tempDateValue = aDateString; if (tempDateValue == null) { tempDateValue = "1970-01-01"; String tempTimeValue; if (aTimeString == null) { tempTimeValue = "T00:00:00.000"; } else { ... |
GregorianCalendar | parseIsoDateInput(String str) parse Iso Date Input GregorianCalendar c = new GregorianCalendar(); c.setTime(isoDateFormatter.parse(str)); return c; |
Date | parseIsoDateTime(String isoDateTime) parse Iso Date Time if (isoDateTime.length() == 0) return new Date(0L); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = df.parse(isoDateTime); return date; |
float[] | parseISODuration(String duration) Parses the specified xsd:duration string. float[] values = new float[7]; int index = 0; if (duration.charAt(index) == '-') { values[0] = -1; index++; } else { values[0] = 1; if (duration.charAt(index) == 'P') { index++; } else { throw new ParseException("missing 'P' designator at [" + index + "]", index); char designator; int offset; int slot; boolean time = false; boolean pending = false; String value = null; while (index < duration.length()) { designator = duration.charAt(index); if (designator == 'T') { time = true; index++; continue; if (isDesignator(designator)) { if (!pending) { throw new ParseException("missing value at [" + index + "]", index); slot = getDesignatorSlot(designator, time); try { values[slot] = getDesignatorValue(designator, value); } catch (NumberFormatException e) { throw new ParseException("malformed value at [" + (index - value.length()) + "]", (index - value.length())); pending = false; index++; continue; offset = getNumberOffset(duration, index); if (offset == index) { throw new ParseException("missing value at [" + index + "]", index); if (offset == duration.length()) { throw new ParseException("missing designator at [" + offset + "]", offset); value = duration.substring(index, offset); index = offset; pending = true; return values; |
long | parseIsoString(String time) parse Iso String return isoFormat.parse(time).getTime();
|
Date | parseTimestampIso8601(String timestamp) Parses the specified timestamp in the ISO 8601 (RFC 3339) format (e.g. SimpleDateFormat f = new SimpleDateFormat(TIMESTAMP_FORMAT_ISO8601, Locale.US); f.setTimeZone(TimeZone.getDefault()); return f.parse(timestamp); |
boolean | strongCheckIso8601Date(String date) full check of whether the date is a valid iso 8601 date or not. if (date == null) { return false; } else { try { parseIso8601Date(date); return true; } catch (ParseException e) { return false; ... |