Java Year Format getyyyyMMddDateStr(Date date)

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

Description

getyyyy M Mdd Date Str

License

Open Source License

Declaration

public static String getyyyyMMddDateStr(Date date) 

Method Source Code

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

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String getyyyyMMddDateStr(Date date) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String strDate = df.format(date);
        return strDate;
    }/*from  w  w w.java  2s .  c  o m*/

    public static String format(Date date, String pattern) {
        if (date == null)
            return "";
        else
            return getFormatter(pattern).format(date);
    }

    public static String format(Date date) {
        if (date == null)
            return "";
        else
            return getFormatter(YYYY_MM_DD).format(date);
    }

    private static SimpleDateFormat getFormatter(String parttern) {
        return new SimpleDateFormat(parttern);
    }
}

Related

  1. getYYYYMM(final Date date, final String separator)
  2. getYYYYMMDD(Date date)
  3. getYYYYMMDD(Date date)
  4. getYYYYMMDD(int y, int m, int d)
  5. getYyyyMMddDate(String s)
  6. getYYYYMMDDFormat()
  7. getYYYYMMDDHH(Date date)
  8. getYYYYMMDDHHMISS()
  9. getYYYYMMDDHHMMSS()