本文介绍了找出本月的第一个星期日/星期一等的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在java中检测每个月的第一个/第二周的第一个星期天/星期一的日期?
我如何实现?
I want to detect date of First Sunday/Monday of first/second week in every month in java?How can I achieve it?
我已经在java中检查了Calendar类和Date类,但无法获得解决方案,请帮助我
I have checked Calendar class as well as Date class in java but not able to get solution for that so please help me out for this.
推荐答案
使用Java 8做最简单的方法是:
The simplest method of doing it with Java 8 is:
LocalDate firstSundayOfNextMonth = LocalDate
.now()
.with(firstDayOfNextMonth())
.with(nextOrSame(DayOfWeek.MONDAY));
这篇关于找出本月的第一个星期日/星期一等的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!