Get starting date of week(configurable starting day of week)

前端 未结 4 364
暖寄归人
暖寄归人 2021-01-20 04:57

I have current date, and a constant which tells from which day the week starts. I want to get the start date of the week based on that constant. If I hardcode the first day

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-20 05:29

    DateTimeFormatter format = DateTimeFormatter.ofPattern("MM/dd/yyyy");
        LocalDate now = LocalDate.now();
    String  startDate = now.with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).format(format);
    

提交回复
热议问题