Here you can find the source of getDateYYYYMMDD()
public static String getDateYYYYMMDD()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getDateYYYYMMDD() { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String NDate = formatter.format(new Date()); return NDate; }/*from w w w. jav a 2s . c o m*/ public static String format(Date date) { return format(date, "yyyy-MM-dd HH:mm:ss"); } public static String format(Date date, String pattern) { return new SimpleDateFormat(pattern).format(date); } }