简体   繁体   中英

QueryDsl - Create a predicate to check if localdate is part of the current week

My goal is to check if a LocalDate is part of the current week. Similar examples for year and month startDate.month().eq(LocalDate.now().getMonthValue()); startDate.year().eq(LocalDate.now().getYear());

Ex 1: 10 - Jun - 2021 (current day) is part if the 7 Jun - 13 Jun. Ex 2: 6 - Jun - 2021 is not part of the current week.

What about:

date.year().eq(DateExpression.currentDate().year())
   .and(date.week().eq(DateExpression.currentDate().week()))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM