Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想计算 2 个 sql 日期之间的天数,我目前正在使用:
Days.daysBetween(new DateMidnight(date1), new DateMidnight(date2));
但是,当传递 sql 日期时1900-01-01,它会变成:1899-12-31.
1900-01-01
1899-12-31
我知道这与时区有关,但是如何防止这种情况发生?
我也尝试过使用: Instants
应避免将 DateMidnight 与时区结合使用。有些日子甚至没有午夜...
尝试使用LocalDate.toDateTimeAtStartOfDay而不是DateMidnight
LocalDate.toDateTimeAtStartOfDay
DateMidnight