Here you can find the source of buildDate(int y, int m, int d)
public static Date buildDate(int y, int m, int d)
//package com.java2s; //License from project: Artistic License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date buildDate(int y, int m, int d) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, y); cal.set(Calendar.MONTH, m - 1); cal.set(Calendar.DAY_OF_MONTH, d); return cal.getTime(); }//www . ja va2 s . c o m public static Date buildDate(int y, int m, int d, int h, int mm, int s) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, y); cal.set(Calendar.MONTH, m - 1); cal.set(Calendar.DAY_OF_MONTH, d); cal.set(Calendar.HOUR_OF_DAY, h); cal.set(Calendar.MINUTE, mm); cal.set(Calendar.SECOND, s); return cal.getTime(); } public static Date buildDate(String strDate) { final String pattern = "yyyy-MM-dd"; return buildDate(strDate, pattern); } public static Date buildDate(String strDate, String pattern) { // TODO Auto-generated method stub SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { return sdf.parse(strDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }