Java SQL Date to String toString(Date date)

Here you can find the source of toString(Date date)

Description

to String

License

Open Source License

Declaration

public static String toString(Date date) 

Method Source Code


//package com.java2s;
/*/*from   w w w  . ja  va 2s  .  c o  m*/
 * All Sigmah code is released under the GNU General Public License v3
 * See COPYRIGHT.txt and LICENSE.txt.
 */

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

public class Main {
    public static String toString(Timestamp timestamp) {
        return timestamp.getTime() + "." + timestamp.getNanos();
    }

    public static String toString(Date date) {
        if (date instanceof Timestamp) {
            return toString((Timestamp) date);
        } else {
            return Long.toString(date.getTime());
        }

    }
}

Related

  1. date2str(java.util.Date date)
  2. date2String(final java.sql.Date value)
  3. toString(Date date)
  4. toString(Date date, String dateFormat)
  5. toString(Date date, String format)
  6. toString(Date obj)
  7. toString(java.sql.Date sqlDate, String format)