Here you can find the source of format(long timestamp)
public static String format(long timestamp)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; public class Main { private static final BlockingQueue<SimpleDateFormat> formats = new ArrayBlockingQueue<SimpleDateFormat>(20); public static String format(long timestamp) { SimpleDateFormat format = formats.poll(); if (format == null) { format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("GMT+8")); }/*from ww w .j a v a 2 s. c o m*/ try { return format.format(new Date(timestamp)); } finally { if (formats.remainingCapacity() > 0) { formats.offer(format); } } } }