Here you can find the source of formatTimestamp(long timestamp)
public static String formatTimestamp(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 { private static transient ThreadLocal<DateFormat> timestampDateFormat = new ThreadLocal<DateFormat>() { @Override//from w ww .j av a 2 s .c o m protected DateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); } @Override public DateFormat get() { return super.get(); } @Override public void set(DateFormat value) { super.set(value); } @Override public void remove() { super.remove(); } }; public static String formatTimestamp(long timestamp) { if (timestamp <= 0) { return "null"; } else { return timestampDateFormat.get().format(new Date(timestamp)); } } }