Java Date Create toDateTime(Date date)

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

Description

to Date Time

License

Open Source License

Declaration

public static String toDateTime(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String toDateTime(Date date) {
        return toDateTime(date, DEFAULT_DATE_TIME_FORMAT);
    }/*from www.jav a2 s .  com*/

    public static String toDateTime(Date dateTime, String pattern) {
        pattern = pattern == null ? "yyyy-MM-dd HH:mm:ss" : pattern;
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        String datastring = format.format(dateTime);
        return datastring;
    }
}

Related

  1. toDateQueryFormat(Date value)
  2. toDateStr(Date d)
  3. ToDateStr(Date dt)
  4. toDateStr(Object o)
  5. toDateText(Date date)
  6. toDatetime(long value)