Here you can find the source of convertTimestampToDateTime(Long timestamp, Boolean withSeconds)
public static String convertTimestampToDateTime(Long timestamp, Boolean withSeconds)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String convertTimestampToDateTime(Long timestamp, Boolean withSeconds) { String result = null;//from ww w. ja v a 2 s . c om SimpleDateFormat sdf; if (withSeconds) { sdf = new SimpleDateFormat("MM/dd/yyyy(HH:mm:ss.SSS)"); } else { sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm"); } Date resultdate = new Date(timestamp); result = sdf.format(resultdate); return result; } }