Java Timestamp Format timestampToString(final Date ts, final String format, final String tzId)

Here you can find the source of timestampToString(final Date ts, final String format, final String tzId)

Description

timestamp To String

License

Open Source License

Parameter

Parameter Description
ts a parameter
format a parameter
tzId a parameter

Declaration

public static String timestampToString(final Date ts, final String format, final String tzId) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

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

public class Main {
    /**/*from   ww w  .  j a v a2 s .  co  m*/
     * 
     * @param ts
     * @param format
     * @param tzId
     * @return
     *
     * @author Anton Nedbailo
     * @date Sep 29, 2013
     */
    public static String timestampToString(final Date ts, final String format, final String tzId) {
        Date ret = ts;
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        formatter.setTimeZone(TimeZone.getTimeZone(tzId));
        if (ret == null) {
            ret = new Date();
        }
        return formatter.format(ret);
    }
}

Related

  1. timeStampForFileName(final String simpleDateFormat)
  2. timestampFormat(Date date)
  3. timestampFormat(final Date date)
  4. timeStampFormat(Timestamp t)
  5. timestampToFormattedDate(Long timestamp)
  6. timestampToString(Long timestamp, String formatStr)
  7. timeToString(long timestamp, SimpleDateFormat format)
  8. toDateFromTimestamp(String timestamp, String format)
  9. toHumanTime(long timestamp, String format)