Java Long Number to Date formatDate(String format, long timestamp)

Here you can find the source of formatDate(String format, long timestamp)

Description

format Date

License

Open Source License

Declaration

public static String formatDate(String format, long timestamp) 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String formatDate(String format, long timestamp) {
        Date date = timestampToDate(timestamp);
        SimpleDateFormat f = new SimpleDateFormat(format);
        return f.format(date);
    }//from   w  w w .  j a va 2s . c  om

    /**
     * Convert a unix timestamp to a Date object. The date object works with milliseconds while unix timestamps are
     * in seconds.
     * @param stamp long
     * @return Date
     */
    public static Date timestampToDate(long stamp) {
        return new Date(stamp * 1000);
    }
}

Related

  1. formatDate(long time)
  2. formatDate(long time, String format)
  3. formatDate(long time_millis)
  4. formatDate(long timeStamp)
  5. formatDate(long timestamp, String format)
  6. formatDate2DateStr(long date)
  7. formatDate2DateStr(long date)
  8. formatDateForLog(long dateTs)
  9. formatDateHeader(final long date)