Here you can find the source of timestampToString(long timestamp)
Parameter | Description |
---|---|
timestamp | the timestamp to be converted. |
public static String timestampToString(long timestamp)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /**/* w ww . j a v a 2 s. c o m*/ * Convert a timestamp in a readable format for a human in the format : YYYY/mm/dd HH:mm:ss * @param timestamp the timestamp to be converted. * @return the human friendly date as mentioned in the description. */ public static String timestampToString(long timestamp) { Calendar cal = GregorianCalendar.getInstance(); timestamp *= 1000; cal.setTimeInMillis(timestamp); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); return cal.get(GregorianCalendar.YEAR) + "-" + (cal.get(GregorianCalendar.MONTH) + 1) + "-" + cal.get(GregorianCalendar.DAY_OF_MONTH) + " " + sdf.format(cal.getTime()); } }