Here you can find the source of yyyyMMdd(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static String yyyyMMdd(Date date)
//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"); } }