Java Date to String dateToString(Date date, String format)

Here you can find the source of dateToString(Date date, String format)

Description

date To String

License

Open Source License

Declaration

public static String dateToString(Date date, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String dateToString(Date date) {

        try {/*w w w .  j  ava  2s.  c  o m*/
            if (date != null)
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
        } catch (Exception e) {
            e.printStackTrace();
            System.gc();
        }
        return null;
    }

    public static String dateToString(Date date, String format) {

        try {
            if (date != null)
                return new SimpleDateFormat(format).format(date);
        } catch (Exception e) {
            e.printStackTrace();
            System.gc();
        }
        return null;
    }
}

Related

  1. dateToString(Date date, String formartStr)
  2. dateToString(Date date, String format)
  3. dateToString(Date date, String format)
  4. dateToString(Date date, String format)
  5. dateToString(Date date, String format)
  6. dateToString(Date date, String format)
  7. dateToString(Date date, String formatStr)
  8. DateToString(Date date, String parttern)
  9. DateToString(Date date, String pattern)