import java.util.Calendar; public class Main { public static void main(String[] args) { // 获取当前日期和时间 Calendar calendar = Calendar.getInstance(); // 获取年 int year = calendar.get(Calendar.YEAR); System.out.println("年份:" + year); // 获取月(注意月份是从0开始的,所以需要加1)...
import java.util.Calendar; public class CalendarTest { public static void main(String[] args){ Calendar cal = Calendar.getInstance(); int day = cal.get(Calendar.DATE); //日 int month = cal.get(Calendar.MONTH) + 1; //月 int year = cal.get(Calendar.YEAR); //年 System.out.println(...
import java.util.Calendar; public class Main { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); // 获取年份 int year = calendar.get(Calendar.YEAR); // 获取月份(月份从0开始,所以需要加1) int month = calendar.get(Calendar.MONTH) + 1; // 获取日期 int...