Java Time Format getFormatDateTime(Date date, String format)

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

Description

get Format Date Time

License

Open Source License

Declaration

public static String getFormatDateTime(Date date, String format) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String DEFAULT_FORMAT = "yyyy-MM-dd";

    public static String getFormatDateTime(Date date, String format) {
        SimpleDateFormat sdf;/*from   w  w  w  .  j  a  v a  2s  .com*/
        if (format == null || format.equalsIgnoreCase("")) {
            sdf = new SimpleDateFormat(DEFAULT_FORMAT);
        } else {
            sdf = new SimpleDateFormat(format);
        }
        return sdf.format(date);
    }
}

Related

  1. getFormat2TimetagStr()
  2. getFormatDate(Date date, boolean ShowTimePart_in)
  3. getFormatDate(String timeString, String format)
  4. getFormatDatetime()
  5. getFormatDateTime(Date date)
  6. getFormatDateTime(java.util.Date date)
  7. getFormattedCurrentDateAndTime()
  8. getFormattedCurrentDateTime(String pattern)
  9. getFormattedDateAndTime(final Date date)