import java.util.Date;
public class DateDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Date d = new Date ();
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//String str = sdf.format(d);
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int day = c.get(Calendar.DAY_OF_MONTH);
String str =year+"-"+month+"-"+day;
sopln(str);
}
public static void sopln(Object obj){
System.out.println(obj);
}
}
|
|