Java SQL Date to String toString(Date date, String dateFormat)

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

Description

to String

License

Open Source License

Declaration

public static String toString(Date date, String dateFormat) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String toString(Date date) {
        return toString(date, "dd/MM/yyyy");
    }//  ww  w.ja v a2  s. c  om

    public static String toString(Date date, String dateFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
        return formatter.format(date);
    }

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

    public static String toString(java.sql.Date date, String dateFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
        return formatter.format(date);
    }

    public static String toString(Timestamp timeStampDate) {
        return toString(timeStampDate, "dd/MM/yyyy");
    }

    public static String toString(Timestamp timeStampDate, String dateFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
        return formatter.format(timeStampDate);
    }
}

Related

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