Java Year Format yyyyMMdd(Date date)

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

Description

yyyy M Mdd

License

Apache License

Parameter

Parameter Description
date a parameter

Declaration

public static String yyyyMMdd(Date date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**//  ww w . j  av a2s. c om
     * 
     * @param date
     * @return
     */
    public static String yyyyMMdd(Date date) {
        return dateFormat4yyyyMMdd().format(date);
    }

    public static String format(DateFormat format, Date date) {
        try {
            return format.format(date);
        } catch (Exception e) {
            throw new IllegalArgumentException("format[" + date + "] with ex.", e);
        }
    }

    public static SimpleDateFormat dateFormat4yyyyMMdd() {
        return new SimpleDateFormat("yyyy-MM-dd");
    }
}

Related

  1. toYYYYMM(Date date)
  2. toYYYYMMDD(Calendar cal)
  3. toYyyyMMddToDate(String date)
  4. unmarshalYYYYMMDD(String date)
  5. yyyyMMdd(Date date)
  6. yyyymmddFormat(Date date)
  7. yyyyMMddFormatter()
  8. yyyyMMddHHmmss2date(String str)
  9. yyyyMMddStringToDate(String date)