Create java.sql.Date Using GregorianCalendar in Java
Description
The following code shows how to create java.sql.Date Using GregorianCalendar.
Example
/*from ww w .j a v a2s .c o m*/
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] args) {
Calendar calendar = new GregorianCalendar(2000, // year
10, // month
1); // day of month
java.sql.Date date = new java.sql.Date(calendar.getTimeInMillis());
System.out.println(date);
}
}
The code above generates the following result.