Create instance of java.sql.Date from Calendar.getTimeInMillis()
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
int year = 2009;
int month = 0; // January
int date = 1;
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, date);
java.sql.Date sqlDate = new java.sql.Date(cal.getTimeInMillis());
System.out.println(sqlDate);
}
}
//2009-01-01
Related examples in the same category