Android Long to Date Convert timestampToIso8601Str(long timestamp)

Here you can find the source of timestampToIso8601Str(long timestamp)

Description

timestamp To Iso Str

License

Open Source License

Declaration

public static String timestampToIso8601Str(long timestamp) 

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//from  ww w  .  j a v  a2s.  c  om
        protected DateFormat initialValue() {
            return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
        }
    };

    public static String timestampToIso8601Str(long timestamp) {
        return javaDateToIso8601(timestampToDate(timestamp));
    }

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

    public static Date timestampToDate(long timeStamp) {
        return new java.util.Date(timeStamp * 1000);
    }
}

Related

  1. timeInMillisecondsToDateStringFull( long timeInMilliseconds)
  2. timestampToDate(long timeStamp)
  3. timestampToDate(long timeStamp)
  4. timestampToISO8601(long aTime)
  5. timestampToIso8601Str(long timestamp)
  6. toCalendar(long hour)
  7. toDateString(long seconds)
  8. toFullDate(long timestamp)
  9. toIso8601(long date, boolean utc)