Android Long to Date Convert timestampToIso8601Str(long timestamp)

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

Description

timestamp To Iso Str

Declaration

public static String timestampToIso8601Str(long timestamp) 

Method Source Code

//package com.java2s;

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/*  ww  w. j a  v a  2s.  c o m*/
        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. timeInMillisToText(final long totalTimeInMillis)
  2. timeInMillisecondsToDateStringFull( long timeInMilliseconds)
  3. timestampToDate(long timeStamp)
  4. timestampToDate(long timeStamp)
  5. timestampToISO8601(long aTime)
  6. timestampToIso8601Str(long timestamp)
  7. toCalendar(long hour)
  8. toDateString(long seconds)
  9. toFullDate(long timestamp)