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

StringformatISO8601()
format ISO
return formatISO8601(new Date());
StringformatISO8601(Date date)
format ISO
if (date == null) {
    return null;
Calendar cal = GregorianCalendar.getInstance();
cal.setTime(date);
cal.setTimeZone(TimeZone.getTimeZone("UTC"));
return DatatypeConverter.printDateTime(cal);
StringformatIso8601(Date date)
Format a date to in ISO 8601 format (as used by GIT) adjusted to UTC timezone.
SimpleDateFormat formatter = createIso8601Format();
formatter.setTimeZone(UTC);
return formatter.format(date);
StringformatIso8601(Date date)
format Iso
if (date == null)
    return "";
String str = format(date, getIso8601DateFormat());
StringBuffer sb = new StringBuffer();
sb.append(str.substring(0, str.length() - 2));
sb.append(":");
sb.append(str.substring(str.length() - 2));
return sb.toString();
...
StringformatISO8601(Date date)
format ISO
return format(date, "yyyy-MM-dd'T'HH:mm:ss.SSS");
StringformatIso8601(Date date)
format Iso
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ISO8601_TS_FORMAT);
return simpleDateFormat.format(date);
StringformatISO8601(Date date, TimeZone timeZone)
Formats a DateTime to a ISO8601 string with a second fraction part of up to 3 digits.
SimpleDateFormat df = null;
if (timeZone != null) {
    df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSSZ");
    df.setTimeZone(timeZone);
    String result = df.format(date);
    if (result.endsWith("0000"))
        return result.replaceAll("[+-]0000$", "Z");
    return result.replaceAll("(\\d{2})(\\d{2})$", "$1:$2");
...
StringformatISO8601(final Date date)
format ISO
if (date == null)
    return "";
SimpleDateFormat dateFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT_PATTERN);
return dateFormat.format(date);
StringformatISO8601(final Date date)
Convert a Date to a ISO8601 string.
Calendar cal = Calendar.getInstance();
cal.setTime(Preconditions.checkNotNull(date, "Date can not be null."));
return DatatypeConverter.printDateTime(cal);
StringformatISO8601Date(Date d)
Convert a Date to String in the ISO 8601 standard format.
String result;
outCal.setTime(d);
if (outCal.get(Calendar.MILLISECOND) == 0) {
    result = outFmtSecond.format(d);
} else {
    result = outFmtMillisec.format(d);
int rl = result.length();
...