Here you can find the source of formatTimestamp(long timestamp)
Parameter | Description |
---|---|
timestamp | Epoch time |
null
if the timestamp is <= 0.
public static String formatTimestamp(long timestamp)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//from w w w .j a v a2 s . com * @param timestamp Epoch time * @return The timestamp formatted as 'HH:mm' or <code>null</code> if the timestamp is <= 0. */ public static String formatTimestamp(long timestamp) { if (timestamp <= 0) return null; SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); return (sdf.format(new Date(timestamp))); } }