Here you can find the source of getTimeStrByTimestamp(long timestamp, String tz)
public static String getTimeStrByTimestamp(long timestamp, String tz)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; public class Main { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static String getTimeStrByTimestamp(long timestamp, String tz) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp); SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DATE_FORMAT); dateFormatGmt.setTimeZone(TimeZone.getTimeZone(tz)); return dateFormatGmt.format(calendar.getTime()); }//from w w w. j a va 2s. co m }