List of utility methods to do Date ISO Parse
String | getADTimeFromISO8601Date(String date) get AD Time From ISO Date SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); return getADTimeFromJavaDate(df.parse(date)); |
Calendar | getCalendarFromISO8601String(final String timestamp, final TimeZone tz) Convert from a ISO8601 style date (YYYY-MM-DDThh:mm:ssZ) string to a Calendar Object. final Calendar cal = Calendar.getInstance(tz); final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); try { cal.setTime(df.parse(timestamp)); } catch (final ParseException pe) { pe.printStackTrace(); return null; return cal; |
String | getISODate(String date) ISO formats a date string. String fecha = ""; try { Date fec = sdf.parse(date); fecha = isoformater.format(fec); } catch (ParseException pe) { pe.printStackTrace(); return fecha; ... |
Long | getISODateInSeconds(String isoDate) Method to get an iso date in the format yyyy, yyyy-mm, or yyyy-mm-dd in GMT seconds String dateString = ""; SimpleDateFormat isodf = new SimpleDateFormat("yyyy-MM-dd"); if (isoDate.matches("\\d{4}")) { dateString = isoDate + "-01-01"; } else if (isoDate.matches("\\d{4}-\\d{2}")) { dateString = isoDate + "-01"; } else if (isoDate.matches("\\d{8}")) { dateString = isoDate; ... |
String | getIsoStringDate(Date date) Gets the date as an ISO 8601 compatible string date. DateFormat format = new SimpleDateFormat(ISO8601); String dateString = format.format(date); return dateString; |
String | getISOStringFromDate(long time) get ISO String From Date SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_FORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); return sdf.format(new Date(time)); |
Date | iso8601(String date) iso try { return newDateFormat().parse(date); } catch (ParseException e) { throw new RuntimeException(e); |
Date | iso86012date(String s) isodate if (s == null) { return null; DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); try { return df.parse(s); } catch (ParseException ex) { return null; |
Calendar | iso8601ToCalendar(String s) Parses a String in ISO-8601 format (GMT zone) and returns an equivalent java.util.Calendar object. Date d = iso8601ToDate(s);
Calendar c = Calendar.getInstance(TIME_ZONE_GMT);
c.setTime(d);
return c;
|
Date | iso8601ToDate(String s) iso To Date Date d = null; try { d = ISO8601_DATE_FORMAT_MILLIS.parse(s); } catch (ParseException e1) { try { d = ISO8601_DATE_FORMAT_SECS.parse(s); } catch (ParseException e2) { try { ... |