我想要找到这个月是相等的还是在当前YearMonth之后
final YearMonth yearMonth = YearMonth.of(2020, 8);
final boolean after = yearMonth.isAfter(YearMonth.now());目前的月份是8月(8),我尝试了返回false的isAfter。
我也想为当月返回真。
YearMonth本身有什么方法吗?
发布于 2020-08-05 14:40:22
您只需使用isBefore方法的否定:
final boolean equalOrAfter = !yearMonth.isBefore(YearMonth.now());毕竟,YearMonth可以是在另一个YearMonth之前、之后还是等于另一个YearMonth之前,所以如果YearMonth是而不是,那么它必须是等于或者是后面的。
发布于 2020-08-05 14:48:06
return yearMonth.getMonth().getValue()>= YearMonth.now().getMonth().getValue();https://stackoverflow.com/questions/63267547
复制相似问题