Java Timestamp to String timestampToString(Timestamp timestamp, String pattern)

Here you can find the source of timestampToString(Timestamp timestamp, String pattern)

Description

timestamp To String

License

Open Source License

Declaration

public static String timestampToString(Timestamp timestamp, String pattern) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

public class Main {

    public static String timestampToString(Timestamp timestamp, String pattern) {
        SimpleDateFormat simpledateformat = new SimpleDateFormat(pattern);
        return simpledateformat.format(timestamp);
    }/*from  w w w .j av a 2  s  .c  om*/

    public static String format(java.util.Date date, String format) {
        String result = "";
        try {
            if (date != null) {
                java.text.DateFormat df = new java.text.SimpleDateFormat(format);
                result = df.format(date);
            }
        } catch (Exception e) {
        }
        return result;
    }

    public static String format(java.util.Date date) {
        return format(date, "yyyy/MM/dd");
    }
}

Related

  1. timeStampToString(Timestamp date, String dateFmt)
  2. timestampToString(Timestamp now, String pattern)
  3. timeStampToString(Timestamp stamp, String dateTimeFormat, TimeZone tz, Locale locale)
  4. timestampToString(Timestamp timestamp)
  5. timestampToString(Timestamp timestamp)
  6. timestampToString(Timestamp ts)
  7. timestampToString(Timestamp ts, Calendar cal)
  8. timestampToStringFF(Timestamp date)
  9. timestampToUTC(Timestamp marcTimestamp)