Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int date = cal.get(Calendar.DATE);

解决方案 »

  1.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
    String year = sdf.format(new Date());
    sdf = new SimpleDateFormat("M");
    String month = sdf.format(new Date());
    sdf = new SimpleDateFormat("d");
    String day = sdf.format(new Date());
      

  2.   

    import java.util.*;Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH) + 1;
    int date = c.get(Calendar.DATE);