关于java如何获取当前年、月、日的方法

public static void main(String[] args) throws ParseException {

Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
System.out.println(year+"---"+month+"---"+day);
}


输出结果:

 

posted @ 2022-02-09 10:27  光光1234  阅读(1430)  评论(0编辑  收藏  举报