import java.time.LocalDate;
import java.time.Month;
import java.util.Date;
public class dateTest {
public static void main(String[] args) {
// System.out.println(new Date());
//
// String s = new Date().toString();
// Date birthday = new Date();
// Date deadline = new Date(); //deadline dosen’t refer to any obgect
// s= deadline.toString();
// System.out.println(s);
// Date deadline = null;
// if (deadline != null)
// System.out.println(deadline);
// else {
// System.out.println(“deadline为null(空 )”);
// System.out.println("______________");
// System.out.println(new Date().toString());
LocalDate newYearsEve = LocalDate.of(1999, 10, 02);
int year = newYearsEve.getYear();
System.out.println("-----");
Month month1 = newYearsEve.getMonth();
System.out.println("-----");
int month2 = newYearsEve.getMonthValue();
int day = newYearsEve.getDayOfMonth();
System.out.println(year);
System.out.println(month1);
System.out.println(month2);
System.out.println(day);
}
}
输出结果:
1999
OCTOBER
10
2
Process finished with exit code 0