Changeset 17722 in josm for trunk


Ignore:
Timestamp:
2021-04-09T01:24:26+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Fix Instant writing in GpsWriter

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r16953 r17722  
    99import java.io.PrintWriter;
    1010import java.nio.charset.StandardCharsets;
     11import java.time.Instant;
    1112import java.util.ArrayList;
    1213import java.util.Collection;
     
    170171                    Object val = obj.get(key);
    171172                    if (val instanceof Date) {
    172                         simpleTag(key, DateUtils.fromDate((Date) val));
     173                        throw new IllegalStateException();
     174                    } else if (val instanceof Instant) {
     175                        simpleTag(key, String.valueOf(val));
    173176                    } else if (val instanceof Number) {
    174177                        simpleTag(key, val.toString());
  • trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java

    r17275 r17722  
    77import java.io.ByteArrayOutputStream;
    88import java.io.IOException;
     9import java.time.Instant;
    910import java.time.LocalDate;
    1011import java.time.Month;
     
    4445        GpxData gpx = new GpxData();
    4546        WayPoint waypoint = new WayPoint(LatLon.ZERO);
     47        waypoint.setInstant(Instant.parse("2019-06-08T08:23:12.300Z"));
    4648        consumer.accept(waypoint);
    4749        gpx.addWaypoint(waypoint);
     
    8991                    w.put(GpxConstants.PT_PDOP, 1.2);
    9092                },
     93                "    <time>2019-06-08T08:23:12.300Z</time>\n" +
    9194                "    <sat>16</sat>\n" +
    9295                "    <hdop>0.7</hdop>\n" +
Note: See TracChangeset for help on using the changeset viewer.