代码:
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
public class POITest {
@Test
public void testReader() throws Exception {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 输出年月日
String result="当前日期是:" + currentDate.getYear() + "年" + (currentDate.getMonthValue() < 10 ? "0" + currentDate.getMonthValue() : currentDate.getMonthValue()) + "月" + (currentDate.getDayOfMonth() < 10 ? "0" + currentDate.getDayOfMonth() : currentDate.getDayOfMonth()+"日");
System.out.println(result);
}
}
效果: