Here you can find the source of format(long millis)
public static String format(long millis)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Map; import java.util.TimeZone; public class Main { public static final String ISO_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss", ISO_DATE_HOUR_FORMAT = "yyyy-MM-dd HH", ISO_DATE_FORMAT = "yyyy-MM-dd", ISO_HOUR_FORMAT = "HH"; private static ThreadLocal<Map<String, DateFormat>> dateFormats = new ThreadLocal<Map<String, DateFormat>>() { public Map<String, DateFormat> get() { return super.get(); }/*from w ww.ja va 2s .c o m*/ protected Map<String, DateFormat> initialValue() { return new HashMap<String, DateFormat>(); } public void remove() { super.remove(); } public void set(Map<String, DateFormat> value) { super.set(value); } }; public static String format(long millis, String format) { return getDateFormat(format).format(millis); } public static String format(long millis) { return format(millis, ISO_DATETIME_FORMAT); } private static DateFormat getDateFormat(String format) { Map<String, DateFormat> threadDateFormats = dateFormats.get(); if (!threadDateFormats.containsKey(format)) { DateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setLenient(false); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); threadDateFormats.put(format, dateFormat); } return threadDateFormats.get(format); } }