Here you can find the source of toDateTime(String timeStamp)
public static String toDateTime(String timeStamp)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; public class Main { public static String toDateTime(String timeStamp) { try {//w w w .jav a2 s . co m Long ts = Long.parseLong(timeStamp) * 1000; DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(new java.util.Date(ts)); } catch (NumberFormatException e) { return ""; } } public static String toDateTime(String timeStamp, String fmt) { try { Long ts = Long.parseLong(timeStamp) * 1000; DateFormat sdf = new SimpleDateFormat(fmt); return sdf.format(new java.util.Date(ts)); } catch (NumberFormatException e) { return ""; } } }