Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { public static String StampToyyyyMMddHHmmss(long stamp) { Date date = null; Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(stamp); date = calendar.getTime(); String format = "yyyy-MM-dd HH:mm:ss.SSSZ"; // String format = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format); //sdf.setTimeZone(TimeZone.getTimeZone("UTC")); sdf.setTimeZone(TimeZone.getTimeZone("PRC")); String time = sdf.format(date); return time.substring(0, "yyyy-MM-dd HH:mm:ss".length()); } }