Java Date Format ISO formatDateISO(Date date)

Here you can find the source of formatDateISO(Date date)

Description

format Date ISO

License

Open Source License

Declaration

public synchronized static String formatDateISO(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String ISO_FORMAT_SECONDS = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    private static final SimpleDateFormat isoFormat = new SimpleDateFormat();

    public static String formatDateISO(long millis) {
        Date d = new Date();
        d.setTime(millis);//  w  w w . j a v a2  s  .  c o  m
        return formatDateISO(d);
    }

    public synchronized static String formatDateISO(Date date) {
        if (date == null) {
            return null;
        }
        isoFormat.applyPattern(ISO_FORMAT_SECONDS);
        return isoFormat.format(date);
    }
}

Related

  1. formatAlternativeIso8601Date(Date date)
  2. formatAsIso8601Timestamp(Date date)
  3. formatAwsFlavouredISO8601Date(Date date)
  4. formatDateAsIsoDate(Calendar calendar)
  5. formatDateAsIsoString(Date date)
  6. formatDateISO(Date date)
  7. formatISO(Integer integerValue)
  8. formatISO8601()
  9. formatIso8601(Date date)