Here you can find the source of getStringFormatFromDateTime(long pDateTime, String format)
Parameter | Description |
---|---|
pDateTime | a parameter |
format | E.g. "dd-MM-yyyy HH:mm:ss Z" |
public static String getStringFormatFromDateTime(long pDateTime, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { private static final String serverTimezone = "Europe/Amsterdam"; /**//from w ww . j ava2 s . com * formats the supplied time in millis to the one specifiedin the format. * @param pDateTime * @param format E.g. "dd-MM-yyyy HH:mm:ss Z" * @return */ public static String getStringFormatFromDateTime(long pDateTime, String format) { format = format != null ? format : "dd-MM-yyyy HH:mm:ss Z"; SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH); dateFormat.setTimeZone(getServerTimeZone()); return dateFormat.format(new Date(pDateTime)); } public static TimeZone getServerTimeZone() { return TimeZone.getTimeZone(serverTimezone); } }