Here you can find the source of formatDateTime(long timestampEpoch)
public static String formatDateTime(long timestampEpoch)
//package com.java2s; /**// www . j a va2s .com * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can * obtain one at http://mozilla.org/MPL/2.0/. * * If it is not possible or desirable to put the notice in a particular file, * then You may include the notice in a location (such as a LICENSE file in a * relevant directory) where a recipient would be likely to look for such a * notice. * * */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Main { private static final SimpleDateFormat dtg = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); public static String formatDateTime(Calendar cal) { synchronized (dtg) { if (cal == null) { return "unknown"; } return dtg.format(cal.getTime()); } } public static String formatDateTime(Date cal) { synchronized (dtg) { if (cal == null) { return "unknown"; } return dtg.format(cal); } } public static String formatDateTime(long timestampEpoch) { synchronized (dtg) { return dtg.format(new Date(timestampEpoch)); } } }