Java Utililty Methods Date Format ISO

List of utility methods to do Date Format ISO

Description

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

Method

StringNowFormatISO()
Now Format ISO
return new SimpleDateFormat(FORMAT_ISO).format(Now());
StringnowISO8601()
Get the current time formatted to ISO8601
final TimeZone tz = TimeZone.getTimeZone("UTC");
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
df.setTimeZone(tz);
return df.format(new Date());
StringparseISODateFormat(String dateStr)
parse ISO Date Format
if (dateStr == null)
    return null;
String val = dateStr;
try {
    if (dateStr.indexOf('T') == 10 && dateStr.endsWith("Z")) {
        Date date = CREATION_DATE_FORMAT.parse(dateStr);
        val = GUNVOR_TOOLS_DATE_FORMAT.format(date);
    } else if (dateStr.indexOf('T') == 10) {
...
DateparseIsoDateTime(final String isoDateString, final String dateFormat)
parse Iso Date Time
final DateFormat df = new SimpleDateFormat(dateFormat);
df.setTimeZone(TimeZone.getDefault());
Date date;
try {
    date = df.parse(isoDateString);
} catch (final ParseException ex) {
    return null;
return date;
StringtimeToIso8601(long time, boolean includeTime)
time To Iso
if (time == 0)
    return null;
Date date = new Date(time);
String formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; 
if (!includeTime)
    formatString = "yyyy-MM-dd"; 
return new SimpleDateFormat(formatString).format(date);
StringtoBasicISO8601DateTime(Date value)
to Basic ISO Date Time
synchronized (basicISO8601DateTimeFormatter) {
    return basicISO8601DateTimeFormatter.format(value);
StringtoDateIso(Date date)
Convert date into a string whose format is yyyy-MM-dd
String val = "";
try {
    val = sdfDateIso.get().format(date);
} catch (Exception e) {
    val = sdfDateIso.get().format(new Date(0));
return val;
StringtoISO2616DateFormat(Date date)
to ISO Date Format
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return dateFormat.format(date);
StringtoIso8601(@Nullable Calendar calendar)
Converts a Calendar -object to a ISO-8601 string.
if (calendar == null) {
    return null;
return javax.xml.bind.DatatypeConverter.printDateTime(calendar);
StringtoIso8601(Date date)
Formats a date into an ISO 8601 string.
if (date == null)
    return null;
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", Locale.US);
fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
return fmt.format(date);