Java Timestamp Create getTimeStrByTimestamp(long timestamp, String tz)

Here you can find the source of getTimeStrByTimestamp(long timestamp, String tz)

Description

get Time Str By Timestamp

License

Apache License

Declaration

public static String getTimeStrByTimestamp(long timestamp, String tz) 

Method Source Code

//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
}

Related

  1. getTimeStampString()
  2. getTimestampString(long timeInMillis)
  3. getTimeStampStringFormat(Timestamp ts, String fmt)
  4. getTimestampToOracle()
  5. getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate)
  6. timestamp()
  7. timeStamp()
  8. timestamp2string()
  9. timestamp4(int unixTime)