简体   繁体   English

QueryDsl - 创建一个谓词来检查 localdate 是否是当前周的一部分

[英]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.我的目标是检查 LocalDate 是否是本周的一部分。 Similar examples for year and month startDate.month().eq(LocalDate.now().getMonthValue());年份和月份的类似示例 startDate.month().eq(LocalDate.now().getMonthValue()); startDate.year().eq(LocalDate.now().getYear()); 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.如果 6 月 7 日 - 6 月 13 日,则 Ex 1:2021 年 6 月 10 日(当天)是一部分。Ex 2:2021 年 6 月 6 日不是本周的一部分。

What about:关于什么:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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