Android Timestamp Format timestampToISO8601(Timestamp aTimestamp)

Here you can find the source of timestampToISO8601(Timestamp aTimestamp)

Description

timestamp To ISO

License

Apache License

Declaration

public static String timestampToISO8601(Timestamp aTimestamp) 

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  a  v  a2  s .  c o 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. formatDate(Timestamp value, String defaultFormat)
  2. formatDateTime(Timestamp value)
  3. formatDateTime(Timestamp value, String defaultFormat)
  4. formatShortDate(Timestamp value)
  5. formatShortDate(Timestamp value, String defaultFormat)
  6. toSloTime(Timestamp time)