我有一个Java应用程序,在该应用程序中,用户无法在特定的日期和时间后修改订单。例如,用户不能在第三天下午12:00之后修改订单,例如是否下达订单11月9日,用户将无法在11月12日中午12:00之后修改oder。日期是动态的,但时间是非常固定的。
我试图使用以下逻辑来计算该时间,但是我无法弄清楚如何从LocalDateTime.now()中提取当前时间进行比较。
final LocalDate orderDate =orderData.getOrderDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
final LocalDate currentDate = LocalDate.now();
final LocalDateTime currentDateTime = LocalDateTime.now();
final LocalDate orderCancellationCutOffDate =
orderDate.minusDays(orderCancellationCutOffDays);
if (currentDate.equals(orderCancellationCutOffDays) &&
currentDateTime.isBefore(<12:00 PM>)){
<Business rule>
}
任何人都可以通过一种有效的方式帮助我进行比较。