Java Hour Format formatDateTime(Date d)

Here you can find the source of formatDateTime(Date d)

Description

format Date Time

License

Open Source License

Declaration

public static String formatDateTime(Date d) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Locale;

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

    public static String formatDateTime(Date d) {
        return format(d, DATETIME_FORMAT);
    }/*ww w . j a v a2s . c  o m*/

    public static String format(Date d, String format) {
        return format(d, format, Locale.getDefault());
    }

    public static String format(Date d, String format, Locale locale) {
        if (d == null)
            return "";
        DateFormat df = new SimpleDateFormat(format, locale);
        return df.format(d);
    }
}

Related

  1. formatDateTime(Calendar cal)
  2. formatDateTime(Calendar dateTime)
  3. formatDateTime(Calendar time)
  4. formatDateTime(Date d)
  5. formatDateTime(Date d)
  6. formatDateTime(Date d)
  7. formatDateTime(Date date)
  8. formatDateTime(Date date)
  9. formatDateTime(Date date)