avoid time zone issues by interpreting all dates and times as UTC
This commit is contained in:
parent
3e66ceee86
commit
07ea116518
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
@ -217,7 +218,9 @@ public class MediaBindingBean {
|
||||||
SimpleDate releaseDate = getReleaseDate();
|
SimpleDate releaseDate = getReleaseDate();
|
||||||
|
|
||||||
if (releaseDate != null) {
|
if (releaseDate != null) {
|
||||||
long days = ChronoUnit.DAYS.between(releaseDate.toLocalDate(), LocalDateTime.now());
|
// avoid time zone issues by interpreting all dates and times as UTC
|
||||||
|
long days = ChronoUnit.DAYS.between(releaseDate.toLocalDate().atStartOfDay(ZoneOffset.UTC), ZonedDateTime.now(ZoneOffset.UTC));
|
||||||
|
|
||||||
if (days >= 0) {
|
if (days >= 0) {
|
||||||
return days;
|
return days;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue