Java Timestamp Create getTimestampDate(long timestamp)

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

Description

get Timestamp Date

License

Open Source License

Declaration

public static String getTimestampDate(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 getTimestampDate(long timestamp) {
        return formatDate("dd.MM.yyyy", timestamp);
    }//from ww  w  .j a v  a 2  s  .c o m

    public static String formatDate(String format, long timestamp) {
        Date date = timestampToDate(timestamp);
        SimpleDateFormat f = new SimpleDateFormat(format);
        return f.format(date);
    }

    /**
     * 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. getTimeStampAsString(Timestamp formatTime)
  2. getTimestampAsString(Timestamp tsTimestamp)
  3. getTimestampAtMidnightForDaysAgo(int days)
  4. getTimestampBeforeMs(long someMs)
  5. getTimeStampByFormat(String style)
  6. getTimestampDate(Timestamp ts)
  7. getTimestampDateDotTime()
  8. getTimestampDiff(int n)
  9. getTimestampedPNGFile(File saveDir)