Android Date to String Convert javaDateToIso8601(Date date)

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

Description

java Date To Iso

License

Open Source License

Declaration

public static String javaDateToIso8601(Date date) 

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
    private static final ThreadLocal<DateFormat> ISO8601Format = new ThreadLocal<DateFormat>() {
        @Override/*w  ww.  jav  a2s  .c  o  m*/
        protected DateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
        }
    };

    public static String javaDateToIso8601(Date date) {
        if (date == null)
            return "";
        DateFormat formatter = ISO8601Format.get();
        return formatter.format(date);
    }
}

Related

  1. getLongDateStr(Date date)
  2. getLongFormat(Date date)
  3. getShortDateTimeString(Date date)
  4. getShortFormat(Date date)
  5. getStringFromDate(Date date)
  6. javaDateToTimeSpan(final Date date)
  7. toGMTDate(Date localDate)
  8. toString(Date date)
  9. getStrFromDate(Date date)