Java Date Format ISO getDateAsISOString(Date date)

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

Description

Creates a string representation of the a date.

License

Apache License

Parameter

Parameter Description
date Date to create string representation for for.

Return

ISO 8601 formatted date time string.

Declaration

public static String getDateAsISOString(Date date) 

Method Source Code

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

import java.util.Calendar;
import java.util.Date;

import javax.xml.bind.DatatypeConverter;

public class Main {
    /**/* ww w  .  j a  v  a2  s . co m*/
     * Creates a string representation of the a date.
     * @param date Date to create string representation for for.
     * @return ISO 8601 formatted date time string.
     */
    public static String getDateAsISOString(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return DatatypeConverter.printDateTime(cal);
    }
}

Related

  1. formatToISO8601(Date date)
  2. formatWikiISO8601(Date d)
  3. fromIso8601(@Nullable String date)
  4. fromIso8601(String iso)
  5. get_ISO_8601()
  6. getFormattedMillisolString(double s)
  7. getIso8601(final Date date)
  8. getISO8601Date(final Date date)
  9. getISO8601Date(long millis)