Ticket #16995: josm-cosmetic-fix-for-GPX-date-strings.patch

File josm-cosmetic-fix-for-GPX-date-strings.patch, 2.0 KB (added by cmuelle8, 6 years ago)

proper fix to timestamp formatting in GPX files, does not append trailing subsecond zeroes

  • src/org/openstreetmap/josm/gui/layer/gpx/ConvertFromGpxLayerAction.java

     
    4242public class ConvertFromGpxLayerAction extends ConvertToDataLayerAction<GpxLayer> {
    4343
    4444    private static final String GPX_SETTING = "gpx.convert-tags";
    45     private final DateFormat timeFormatter = DateUtils.getGpxFormat();
    4645
    4746    /**
    4847     * Creates a new {@code FromGpxLayer}.
     
    8281                            // timestamps should always be converted
    8382                            Date date = (Date) obj;
    8483                            if (!none) { //... but the tag will only be set when required
    85                                 n.put(key, timeFormatter.format(date));
     84                                n.put(key, DateUtils.fromDate(date));
    8685                            }
    8786                            n.setTimestamp(date);
    8887                        }
  • src/org/openstreetmap/josm/io/GpxWriter.java

     
    3737 */
    3838public class GpxWriter extends XmlWriter implements GpxConstants {
    3939
    40     private final DateFormat gpxFormat = DateUtils.getGpxFormat();
    41 
    4240    /**
    4341     * Constructs a new {@code GpxWriter}.
    4442     * @param out The output writer
     
    120118                } else {
    121119                    Object val = obj.get(key);
    122120                    if (val instanceof Date) {
    123                         simpleTag(key, gpxFormat.format(val));
     121                        simpleTag(key, DateUtils.fromDate((Date) val));
    124122                    } else if (val instanceof Number) {
    125123                        simpleTag(key, val.toString());
    126124                    } else if (val != null) {