Java Timestamp to String timeStampToString(Timestamp date, String dateFmt)

Here you can find the source of timeStampToString(Timestamp date, String dateFmt)

Description

time Stamp To String

License

Apache License

Declaration

public static String timeStampToString(Timestamp date, String dateFmt) 

Method Source Code


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

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

public class Main {
    public static String timeStampToString(Timestamp date, String dateFmt) {
        String strTemp = null;//from  w w  w  .  j a  va 2  s. co m
        if (date != null) {
            String dtFmt = dateFmt;
            if (null == dtFmt)
                dtFmt = "yyyy-MM-dd";
            SimpleDateFormat formatter = new SimpleDateFormat(dtFmt);
            strTemp = formatter.format(date);
        }
        return strTemp;
    }

    public static String timeStampToString(Timestamp date) {
        return timeStampToString(date, null);
    }

    public static String format(java.util.Date date) {
        return date == null ? "" : format(date, "yyyy-MM-dd");
    }

    public static String format(java.util.Date date, String pattern) {
        return date == null ? "" : new SimpleDateFormat(pattern).format(date);
    }
}

Related

  1. timestamptoStr(Timestamp time)
  2. timeStampToString(final Timestamp timestamp, final String format)
  3. timestampToString(java.sql.Timestamp a_Timestamp, String aS_Format)
  4. timestampToString(long timestamp)
  5. timestampToString(long timestamp)
  6. timestampToString(Timestamp now, String pattern)
  7. timeStampToString(Timestamp stamp, String dateTimeFormat, TimeZone tz, Locale locale)
  8. timestampToString(Timestamp timestamp)
  9. timestampToString(Timestamp timestamp)