Date date = new Date();

String year = String.format("%tY", date);

String month = String.format("%tB", date);

String day = String.format("%te", date);

System.out.println("今天是:"+year+"-"+month+"-"+day);



Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("date是"+sdf.format(date));
System.out.println("今天是"+sdf.format(date));
System.out.println("昨天是"+sdf.format(new Date(date.getTime()-60*60*1000*24L)));
System.out.println("30前天是"+sdf.format(new Date(date.getTime()-60*60*1000*24*30L)));