Java Timestamp Convert To toFormatedString(final Timestamp ts, final String timeZoneId)

Here you can find the source of toFormatedString(final Timestamp ts, final String timeZoneId)

Description

to Formated String

License

Open Source License

Parameter

Parameter Description
ts a Timestamp
timeZoneId Id of TimeZone

Return

a String formated with SimpleDateFormat

Declaration

public static String toFormatedString(final Timestamp ts, final String timeZoneId) 

Method Source Code


//package com.java2s;
import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.TimeZone;

public class Main {
    public static final String STANDARD_DATETIMEFORMAT = "dd.MM.yyyy HH:mm";

    /**/*from ww w.ja  va 2 s  .  c  om*/
     * @param ts a Timestamp
     * @param timeZoneId Id of TimeZone
     * @return a String formated with SimpleDateFormat
     */
    public static String toFormatedString(final Timestamp ts, final String timeZoneId) {
        SimpleDateFormat df = new SimpleDateFormat(STANDARD_DATETIMEFORMAT);
        df.setTimeZone(TimeZone.getTimeZone(timeZoneId));
        return df.format(ts.getTime());
    }
}

Related

  1. toDateTime(Timestamp value)
  2. toDecimal(Timestamp instant)
  3. toEnglishDateTime(java.sql.Timestamp ts)
  4. toEnglishHours(java.sql.Timestamp ts)
  5. toEPICSTime(java.sql.Timestamp timestamp)
  6. toGmtTimestampString(Timestamp timestamp)
  7. toInstant(final Timestamp timestamp)
  8. toJavaDate(Timestamp dt)
  9. toLocalDateTime(Timestamp timestamp)