Java Date Format As formatDateYMD(Object date)

Here you can find the source of formatDateYMD(Object date)

Description

format Date YMD

License

Apache License

Declaration

public static String formatDateYMD(Object 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 formatDateYMD(Object date) {
        return formatDate(date, "yyyy-MM-dd");
    }/*  ww w  . j ava  2s  . c  o m*/

    public static String formatDate(Object date, String fmt) {
        if (date == null) {
            return null;
        }
        if (!(date instanceof Date)) {
            return date.toString();
        }
        SimpleDateFormat sdf = new SimpleDateFormat(fmt);
        return sdf.format(date);
    }
}

Related

  1. formatDateUsingW3C(Date date)
  2. formatDateUTC(Date d)
  3. formatDateUTC(Date date)
  4. formatDateW3C(Date date)
  5. formatDateWithMilliseconds(DateFormat aFormat, Date aDate)
  6. formatDateYyyymmddhhmmss(Date date)
  7. formatDatum(Date date, Locale locale)
  8. formatDay(Date date)
  9. formatDay(java.util.Date d)