Java Long Number to Timestamp timestamp2Date(long timestamp, String timezone)

Here you can find the source of timestamp2Date(long timestamp, String timezone)

Description

timestamp Date

License

Apache License

Declaration

public static Date timestamp2Date(long timestamp, String timezone) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.TimeZone;

public class Main {
    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Date timestamp2Date(long timestamp, String timezone) throws ParseException {
        SimpleDateFormat dateFormatGmt = new SimpleDateFormat(DATE_FORMAT);
        dateFormatGmt.setTimeZone(TimeZone.getTimeZone(timezone));

        SimpleDateFormat dateFormatLocal = new SimpleDateFormat(DATE_FORMAT);

        return dateFormatLocal.parse(dateFormatGmt.format(new Date(timestamp)));
    }/*from   w  ww .  ja va 2 s  .c  o  m*/
}

Related

  1. prettyPrintDate(long timestamp)
  2. printTimestamp(Long c)
  3. reverseTimestampToNormalTime(long timestamp)
  4. timestamp(long time)
  5. timestamp2DataTime(long timestamp)
  6. timestamp2DateTime(long t)
  7. timestampToHumanDateAndTime(long timestamp)
  8. timestampToString(long micros)
  9. timestampToString(long time)