Here you can find the source of formatTimeToString(long timestamp)
public static String formatTimeToString(long timestamp)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; public class Main { private static final String ES_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; private static final ThreadLocal<DateFormat> timef = new ThreadLocal<>(); public static String formatTimeToString(long timestamp) { DateFormat sdf = timef.get(); if (sdf == null) { sdf = new SimpleDateFormat(ES_DATE_FORMAT); timef.set(sdf);/*from w ww .j av a 2 s . c om*/ } return sdf.format(timestamp); } }