From 2b7fb2cb00bdcfe6edd6cdce2823200314dea771 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 26 Dec 2016 20:32:17 +0100 Subject: [PATCH] Revert "refactoring and fix for #2403" This reverts commit cf094bb66000485d1e42476e4739079de462422d. --- .../sf/jabref/gui/date/DatePickerButton.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/sf/jabref/gui/date/DatePickerButton.java b/src/main/java/net/sf/jabref/gui/date/DatePickerButton.java index 82c248afd76..dd7b0058c10 100644 --- a/src/main/java/net/sf/jabref/gui/date/DatePickerButton.java +++ b/src/main/java/net/sf/jabref/gui/date/DatePickerButton.java @@ -10,6 +10,7 @@ import net.sf.jabref.Globals; import net.sf.jabref.gui.IconTheme; import net.sf.jabref.gui.fieldeditors.FieldEditor; +import net.sf.jabref.logic.util.date.EasyDateFormat; import net.sf.jabref.preferences.JabRefPreferences; import com.github.lgooddatepicker.components.DatePicker; @@ -25,16 +26,11 @@ public class DatePickerButton implements DateChangeListener { private final DatePicker datePicker; private final JPanel panel = new JPanel(); private final FieldEditor editor; - private final DateTimeFormatter dateTimeFormatter; + private final boolean isoFormat; - public DatePickerButton(FieldEditor pEditor, boolean useIsoFormat) { - if (useIsoFormat) { - dateTimeFormatter = DateTimeFormatter.ISO_DATE; - } else { - dateTimeFormatter = DateTimeFormatter.ofPattern(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT)); - } - + public DatePickerButton(FieldEditor pEditor, Boolean isoFormat) { + this.isoFormat = isoFormat; // Create a date picker with hidden text field (showing button only). DatePickerSettings dateSettings = new DatePickerSettings(); dateSettings.setVisibleDateTextField(false); @@ -54,9 +50,13 @@ public DatePickerButton(FieldEditor pEditor, boolean useIsoFormat) { public void dateChanged(DateChangeEvent dateChangeEvent) { LocalDate date = datePicker.getDate(); if (date != null) { - editor.setText(dateTimeFormatter.format(date.atStartOfDay())); + if (isoFormat) { + editor.setText(date.format(DateTimeFormatter.ISO_DATE)); + } else { + EasyDateFormat.fromTimeStampFormat(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT)).getDateAt(date.atStartOfDay()); + } } else { - // in this case the user selected "clear" in the date picker, so we just clear the field + // in this case the user selected "none" in the date picker, so we just clear the field editor.setText(""); } // Set focus to editor component after changing its text: