Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); public static String formatSimpleDateStr(int year, int monthOfYear, int dayOfMonth) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, monthOfYear); cal.set(Calendar.DATE, dayOfMonth); return SIMPLE_DATE_FORMAT.format(cal.getTime()); } public static String formatSimpleDateStr(Date date) { return SIMPLE_DATE_FORMAT.format(date); } }