Here you can find the source of toDateHeader(long value)
public static String toDateHeader(long value)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import java.util.Date; public class Main { /**//w w w . j a v a2 s . co m * Per thread pre-initialized date formatters */ private static final ThreadLocal<SimpleDateFormat[]> DATE_FORMATS = new ThreadLocal<SimpleDateFormat[]>() { @Override protected synchronized SimpleDateFormat[] initialValue() { SimpleDateFormat[] fmts = new SimpleDateFormat[] { // The first two formats are the same because we use fmts[0] for // parsing and fmts[1] for formatting. We uses separate objects for // these tasks because parsing a date actually modifies the // timezone that the formatting object uses for formatting. new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; fmts[0].setTimeZone(TimeZone.getTimeZone("GMT")); fmts[1].setTimeZone(TimeZone.getTimeZone("GMT")); fmts[2].setTimeZone(TimeZone.getTimeZone("GMT")); fmts[3].setTimeZone(TimeZone.getTimeZone("GMT")); return fmts; } }; public static String toDateHeader(long value) { final SimpleDateFormat[] formats = DATE_FORMATS.get(); return formats[0].format(new Date(value)); } }