import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateDemo {
public static void main(String[] args) {
/*
* 日期第一种写法
*/
java.util.Date dNow = new java.util.Date( );
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");
System.out.println(ft.format(dNow));
/*
* 日期第二种写法
*/
Calendar today = Calendar.getInstance();
int year = today.get(Calendar.YEAR);
int month = today.get(Calendar.MONTH)+1;
int day = today.get(Calendar.DATE);
System.out.println(year+"-"+month+"-"+day);
/*
* 日期第三种写法
*/
java.sql.Date day1 = new java.sql.Date(System.currentTimeMillis());
System.out.println(day1);
}
}