Android Date Format timestampToISO8601(Date aDate)

Here you can find the source of timestampToISO8601(Date aDate)

Description

timestamp To ISO

License

Apache License

Declaration

public static String timestampToISO8601(Date aDate) 

Method Source Code

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

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String timestampToISO8601(Timestamp aTimestamp) {
        return timestampToISO8601(new Date(aTimestamp.getTime()));
    }//from  ww w  .  j  ava  2  s .co  m

    public static String timestampToISO8601(long aTime) {
        return timestampToISO8601(new Date(aTime));
    }

    public static String timestampToISO8601(Date aDate) {
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ssZ");
        return format.format(aDate);
    }

    public static String format(String aFormat, long aDate) {
        SimpleDateFormat format = new SimpleDateFormat(aFormat);
        return format.format(new Date(aDate));
    }
}

Related

  1. getFormatTime(Date date)
  2. getFormatTomorrow(String format)
  3. getFormatYestoday(String format)
  4. getUniversalDateStamp(Date date)
  5. getUtcTimeStringFromDate(Date date)
  6. toDateString(Date value)
  7. toDateTimeString(Date value)
  8. toRelativeDateString(Date value)
  9. toString(Date date, String format)