Java Date Format ISO formatISO8601(Date date)

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

Description

format ISO

License

Apache License

Declaration

public static String formatISO8601(Date date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.xml.bind.DatatypeConverter;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    public static String formatISO8601(Date date) {
        if (date == null) {
            return null;
        }//w  ww. jav a2s  . c  o  m
        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(date);
        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
        return DatatypeConverter.printDateTime(cal);
    }
}

Related

  1. formatDateISO(Date date)
  2. formatISO(Integer integerValue)
  3. formatISO8601()
  4. formatIso8601(Date date)
  5. formatIso8601(Date date)
  6. formatISO8601(Date date)
  7. formatIso8601(Date date)
  8. formatISO8601(Date date, TimeZone timeZone)
  9. formatISO8601(final Date date)