Calendar获取这个月,周,日

    xiaoxiao2022-07-04  117

    public class TestDate { public static void main(String[] args) { // 2019-05-22 Calendar cal = Calendar.getInstance(); System.out.println(cal.get(Calendar.MONTH) + 1); System.out.println(cal.get(Calendar.DAY_OF_MONTH)); System.out.println(cal.get(Calendar.WEEK_OF_MONTH)); System.out.println(cal.get(Calendar.DAY_OF_WEEK)); } }

    2019-05-22执行效果如下:5月,22日,第四周,第四周的第四天(周日为第一天)

    最新回复(0)