Java Long Number to Timestamp longToDateTime(long timestamp)

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

Description

Return formatted Date String: yyyy.MM.dd HH:mm:ss Based on Unix's time() input in seconds

License

Open Source License

Parameter

Parameter Description
timestamp seconds since start of Unix-time

Return

String formatted as - yyyy.MM.dd HH:mm:ss

Declaration

public static String longToDateTime(long timestamp) 

Method Source Code

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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /** //  www  . j  a v  a  2s .  c o m
     * Return formatted Date String: yyyy.MM.dd HH:mm:ss
     * Based on Unix's time() input in seconds
     * 
     * @param timestamp seconds since start of Unix-time
     * @return String formatted as - yyyy.MM.dd HH:mm:ss
     */
    public static String longToDateTime(long timestamp) {
        Date date = new Date(timestamp * 1000);
        DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
        return formatter.format(date);
    }
}

Related

  1. addSecondsToTimeStamp(Long timestamp, int seconds)
  2. getCompactStringTimestamp(long timestamp)
  3. getIndex(String index, long timestamp)
  4. longToDate(long timestamp)
  5. longToDateTime(long timestamp)
  6. prettyPrintDate(long timestamp)
  7. printTimestamp(Long c)
  8. reverseTimestampToNormalTime(long timestamp)
  9. timestamp(long time)