Java Date Time to String DateTimeToString(Date date)

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

Description

Date Time To String

License

Apache License

Declaration

public static String DateTimeToString(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String DateTimeToString(Date date) {
        String _pattern = "yyyy-MM-dd HH:mm:ss";
        return date == null ? null : DateToString(date, _pattern);
    }// w  w  w .  j  a v  a  2  s . com

    public static String DateToString(Date date, String pattern) {
        String strDateTime = null;
        SimpleDateFormat formater = new SimpleDateFormat(pattern);
        strDateTime = date == null ? null : formater.format(date);
        return strDateTime;
    }

    public static String DateToString(Date date) {
        String _pattern = "yyyy-MM-dd";
        return date == null ? null : DateToString(date, _pattern);
    }
}

Related

  1. dateTimeToString(Calendar dateTime)
  2. dateTimeToString(Date d)
  3. dateTimeToString(Date d)
  4. dateTimeToString(Date date)
  5. dateTimeToString(Date date)
  6. dateTimeToString(Date date)
  7. dateTimeToString(Date date, String formatter)
  8. dateTimeToString(final Date date)