ErrorProne: fix base/JavaTimeDefaultTimeZone

This commit is contained in:
mkpaz 2023-02-09 15:01:37 +04:00
parent fb722c9870
commit 82b221dc33
2 changed files with 10 additions and 4 deletions

@ -5,6 +5,7 @@ import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import static atlantafx.base.util.PlatformUtils.isMac; import static atlantafx.base.util.PlatformUtils.isMac;
import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.MONTHS;
@ -24,7 +25,7 @@ public class InlineDatePickerBehavior extends BehaviorBase<InlineDatePicker, Inl
if (e.getEventType() == KeyEvent.KEY_PRESSED) { if (e.getEventType() == KeyEvent.KEY_PRESSED) {
switch (e.getCode()) { switch (e.getCode()) {
case HOME -> { case HOME -> {
getSkin().goToDate(LocalDate.now(), true); getSkin().goToDate(LocalDate.now(ZoneId.systemDefault()), true);
e.consume(); e.consume();
} }
case PAGE_UP -> { case PAGE_UP -> {

@ -45,6 +45,7 @@ import javafx.util.Callback;
import java.time.DateTimeException; import java.time.DateTimeException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.ZoneId;
import java.time.chrono.ChronoLocalDate; import java.time.chrono.ChronoLocalDate;
import java.time.chrono.Chronology; import java.time.chrono.Chronology;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -105,7 +106,9 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
registerChangeListener(datePicker.valueProperty(), e -> { registerChangeListener(datePicker.valueProperty(), e -> {
LocalDate date = datePicker.getValue(); LocalDate date = datePicker.getValue();
displayedYearMonthProperty().set((date != null) ? YearMonth.from(date) : YearMonth.now()); displayedYearMonthProperty().set(
date != null ? YearMonth.from(date) : YearMonth.now(ZoneId.systemDefault())
);
updateValues(); updateValues();
datePicker.fireEvent(new ActionEvent()); datePicker.fireEvent(new ActionEvent());
}); });
@ -185,7 +188,9 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
// YearMonth // // YearMonth //
LocalDate value = getControl().getValue(); LocalDate value = getControl().getValue();
displayedYearMonth.set(value != null ? YearMonth.from(value) : YearMonth.now()); displayedYearMonth.set(
value != null ? YearMonth.from(value) : YearMonth.now(ZoneId.systemDefault())
);
displayedYearMonth.addListener((observable, oldValue, newValue) -> updateValues()); displayedYearMonth.addListener((observable, oldValue, newValue) -> updateValues());
rootPane.getChildren().add(createMonthYearPane()); rootPane.getChildren().add(createMonthYearPane());
@ -611,6 +616,6 @@ public class InlineDatePickerSkin extends BehaviorSkinBase<InlineDatePicker, Inl
} }
private static LocalDate today() { private static LocalDate today() {
return LocalDate.now(); return LocalDate.now(ZoneId.systemDefault());
} }
} }