Code example for ParseException

0
            iso8601String = iso8601String.replace("Z", "+00:00"); //$NON-NLS-1$ //$NON-NLS-2$
            try { 
                iso8601String = iso8601String.substring(0, 22) + iso8601String.substring(23);
            } catch (IndexOutOfBoundsException e) {
                e.printStackTrace();
                throw new ParseException("Invalid ISO 8601 length for string " + iso8601String, 0); //$NON-NLS-1$
            } 
            formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$
        } else { 
            formatString = "yyyy-MM-dd"; //$NON-NLS-1$
        } 
 
        Date result = new SimpleDateFormat(formatString).parse(iso8601String);
        return result.getTime();
    } 
 
    public static String timeToIso8601(long time, boolean includeTime) {
        if (time == 0)
            return null; 
        Date date = new Date(time);
Contextual code suggestions in your IDE  Get Codota for Java