如何检查两个 LocalTimes 是否在同一天?

How to check if two LocalTimes are in the same day?

从我的 UI 我正在传递两个 LocalTime 值;不时地。两次都是

LocalTime HH:mm

格式化。 现在我需要检查这些时间是否在同一天。 例如,如果有人通过 fromTime - 18:00 和 toTime - 10:00,我需要抛出异常。 我需要检查两个时间是否在同一天。

我尝试使用 DateUtils.isSameDay() 但它接受日期。就我而言,我只有时间。

感谢您的帮助。

谢谢

LocalTime does not store or represent a date 或时区。所以你不能检查两个实例是否在同一日期。

看看“从”时间是[​​=13=]“到”时间。

如果您还需要存储日期,请使用 LocalDateTime