這個(gè)要怎么做,求大神解答。
2 回答
已采納

car
TA貢獻(xiàn)184條經(jīng)驗(yàn) 獲得超33個(gè)贊
public?class?TestMain?{ ????public?static?void?main(String[]?args)?{ ????????int?n?=?1;//輸入的日期數(shù)字1-7 ????????LocalDate?date?=?LocalDate.now(); ????????int?year?=?date.getYear(); ????????LocalDate?startDate?=?LocalDate.parse(year+"-01-01"); ????????LocalDate?endDate?=?LocalDate.parse(year+"-12-31"); ????????int?startDay?=?startDate.getDayOfYear(); ????????int?endDay?=?endDate.getDayOfYear(); ????????DayOfWeek?dayOfWeek?=?null; ????????while?(startDay?<=?endDay)?{ ????????????dayOfWeek?=?startDate.getDayOfWeek(); ????????????int?value?=?dayOfWeek.getValue(); ????????????if?(value?==?n)?{ ????????????????System.out.println(startDate); ????????????} ????????????startDate?=?startDate.plusDays(1); ????????????startDay++; ????????} ????} }
添加回答
舉報(bào)
0/150
提交
取消