Changeset 17910 in josm for trunk/src/org


Ignore:
Timestamp:
2021-05-24T12:13:56+02:00 (4 years ago)
Author:
simon04
Message:

fix #20875 - Use same DateFormat for formatting/parsing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r17880 r17910  
    2929import java.text.SimpleDateFormat;
    3030import java.time.Instant;
    31 import java.time.ZoneOffset;
    32 import java.time.format.DateTimeFormatter;
    33 import java.time.format.FormatStyle;
    3431import java.util.ArrayList;
    3532import java.util.Arrays;
    3633import java.util.Collections;
    3734import java.util.Comparator;
     35import java.util.Date;
    3836import java.util.Dictionary;
    3937import java.util.Hashtable;
     
    598596        }
    599597
     598        private SimpleDateFormat getDateTimeFormat() {
     599            return (SimpleDateFormat) DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM);
     600        }
     601
    600602        @Override
    601603        public void actionPerformed(ActionEvent e) {
    602             SimpleDateFormat dateFormat = (SimpleDateFormat) DateUtils.getDateTimeFormat(DateFormat.SHORT, DateFormat.MEDIUM);
     604            SimpleDateFormat dateFormat = getDateTimeFormat();
    603605
    604606            JPanel panel = new JPanel(new BorderLayout());
     
    773775            Instant date = img.getExifInstant();
    774776            if (date != null) {
    775                 DateTimeFormatter df = DateUtils.getDateTimeFormatter(FormatStyle.SHORT, FormatStyle.MEDIUM)
    776                         .withZone(ZoneOffset.UTC); // EXIF data does not contain timezone information and is read as UTC
    777                 lbExifTime.setText(df.format(date));
    778                 tfGpsTime.setText(df.format(date));
     777                DateFormat df = getDateTimeFormat();
     778                df.setTimeZone(DateUtils.UTC); // EXIF data does not contain timezone information and is read as UTC
     779                lbExifTime.setText(df.format(Date.from(date)));
     780                tfGpsTime.setText(df.format(Date.from(date)));
    779781                tfGpsTime.setCaretPosition(tfGpsTime.getText().length());
    780782                tfGpsTime.setEnabled(true);
Note: See TracChangeset for help on using the changeset viewer.