import java.util.Date;
public class showDate{
@Test
public void showDate(){
Date date=new Date();
//SimpleDateFormat format =new SimpleDateFormat("yyyy-MM-dd");
String year=String.format("%tY",date);
String month=String.format("%tB",date);
String day=String.format("%td",date);
System.out.println("今年是"+year+"年");
System.out.println("现在是"+month+"月");
System.out.println("今天是"+day+"号");
}
}
测试结果如图所示: