Java Utililty Methods Date ISO Parse

List of utility methods to do Date ISO Parse

Description

The list of methods to do Date ISO Parse are organized into topic(s).

Method

DateparseDateISO(String value)
parse Date ISO
if (value == null) {
    return null;
synchronized (sdf) {
    sdf.applyPattern(ISO_FORMAT_SECONDS);
    sdf.setTimeZone(GMT);
    sdf.setLenient(true);
    try {
...
DateTimeparseDateTime(String iso8061StrDateTime)
parse Date Time
if (iso8061StrDateTime == null) {
    return null;
try {
    return ATHENA_DATE_TIME_FORMAT.parseDateTime(iso8061StrDateTime);
} catch (IllegalArgumentException iae) {
    return ATHENA_DATE_FORMAT.parseDateTime(iso8061StrDateTime);
DateparseFromIso8601(String s)
Parses a string in ISO8601 format to a Date object
synchronized (MONITOR) {
    try {
        return ISO8601.parse(s);
    } catch (ParseException e) {
        throw new IllegalArgumentException("Unable to parse date", e);
DateparseISO(String aIsoString)
Aggiunge 12:00 per evitare problemi con CET CEST.
return new SimpleDateFormat(FORMAT_ISO_HHmm).parse(aIsoString + " 12:00");
DateparseISO(String input)
parse ISO
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
if (input.endsWith("Z")) {
    input = input.substring(0, input.length() - 1) + "GMT-00:00";
} else {
    int inset = 6;
    String s0 = input.substring(0, input.length() - inset);
    String s1 = input.substring(input.length() - inset, input.length());
    input = s0 + "GMT" + s1;
...
DoubleparseISO(String strValue)
Formats a double value according to the ISO format for double
if (strValue != null) {
    try {
        Number number = isoDoubleFormat.parse(strValue);
        if (number != null) {
            return new Double(number.doubleValue());
    } catch (ParseException e) {
return null;
longparseIso8601(String iso8601String)
parse Iso
if (iso8601String == null)
    return 0;
String formatString;
if (isoStringHasTime(iso8601String)) { 
    iso8601String = iso8601String.replace("Z", "+00:00"); 
    try {
        iso8601String = iso8601String.substring(0, 22) + iso8601String.substring(23);
    } catch (IndexOutOfBoundsException e) {
...
DateparseIso8601(String rawstr)
parse Iso
return createIso8601Format().parse(rawstr);
DateparseIso8601(String time)
Not working yet but this is supposed to parse an iso8601 date format
String tmp = "((\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d))?(T(\\d\\d):(\\d\\d)(:(\\d\\d)?)?(.*)?)?";
Pattern pattern = Pattern.compile(tmp);
Matcher matcher = pattern.matcher(time);
boolean ok = matcher.find();
if (!ok) {
    System.err.println("No match:" + time);
    return null;
System.err.println("Time:" + time);
for (int i = 1; i <= matcher.groupCount(); i++) {
int gidx = 1;
gidx++;
String year = str(matcher.group(gidx++), "0000");
String month = str(matcher.group(gidx++), "01");
String day = str(matcher.group(gidx++), "01");
gidx++;
String hh = str(matcher.group(gidx++), "00");
String mm = str(matcher.group(gidx++), "00");
gidx++;
String ss = str(matcher.group(gidx++), "00");
String tzd = str(matcher.group(gidx++), "GMT");
if (tzd.equals("Z") || (tzd.length() == 0)) {
    tzd = "GMT";
String format = "yyyy-MM-dd-HH-mm-ss-Z";
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern(format);
String dateString = year + "-" + month + "-" + day + "-" + hh + "-" + mm + "-" + ss + "-" + tzd;
try {
    Date dttm = sdf.parse(dateString);
    return dttm;
} catch (Exception exc) {
    System.err.println("exc:" + exc);
    return null;
CalendarparseISO8601Date(final String dateString)
Parse the date contained in the supplied string and return a UTC Calendar object.
final String regex = "^(\\d{4})-?(([wW]([012345]\\d)-?([1234567])?)|(([01]\\d)(-([0123]\\d))?)|([01]\\d)([0123]\\d)|([0123]\\d\\d))?(T([012]\\d):?([012345]\\d)?(:?([012345]\\d)(.(\\d{1,3}))?)?)?((Z)|(([+-])(\\d{2})):?(\\d{2})?)?$";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(dateString);
if (!matcher.matches()) {
    throw new ParseException("error while parsing iso8601 date: " + dateString, 0);
String year = matcher.group(1);
String week = matcher.group(4);
...