Here you can find the source of longToDateTime(long timestamp)
Parameter | Description |
---|---|
timestamp | seconds since start of Unix-time |
public static String longToDateTime(long timestamp)
//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); } }