日期:2014-05-20 浏览次数:20848 次
import java.util.Date;
public class ttt {
public static void main(String[] args) {
Date today=new Date();
String date=today.getYear()+"-"+today.getMonth()+"-"+today.getDay();
System.out.println("现在的日期是"+date);
}
}
Date today=new Date();
String date= new SimpleDateFormat("yy-mm-dd").format(today);
System.out.println("现在的日期是"+date);
------解决方案--------------------
@Deprecated
public int getYear() {
return normalize().getYear() - 1900;
}
@Deprecated
public int getMonth() {
return normalize().getMonth() - 1; // adjust 1-based to 0-based
}
@Deprecated
public int getDay() {
return normalize().getDayOfWeek() - gcal.SUNDAY;
}