Java SQL Date to String toString(Object object)

Here you can find the source of toString(Object object)

Description

to String

License

Open Source License

Parameter

Parameter Description
object a parameter

Declaration

protected static String toString(Object object) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**/*from  w  ww.  j  a va 2  s.  c o  m*/
     * 
     * @param object
     * @return
     */
    protected static String toString(Object object) {
        if (object == null) {
            return "";
        } else if (object instanceof Date) {
            return df.format(object);
        } else if (object instanceof Timestamp) {
            return df.format(object);
        } else
            return object.toString();
    }
}

Related

  1. toString(Date date, String dateFormat)
  2. toString(Date date, String format)
  3. toString(Date obj)
  4. toString(java.sql.Date sqlDate, String format)
  5. toString(Object date)
  6. toStringTH(Date date, String dateFormat)
  7. toStringValue(Date date)