Changeset 14445 in josm


Ignore:
Timestamp:
2018-11-23T20:59:30+01:00 (5 months ago)
Author:
Don-vip
Message:

fix #16995 - use exclusively Date objects in waypoints (patch by cmuelle8, modified)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r14434 r14445  
    33
    44import java.awt.Color;
    5 import java.time.DateTimeException;
    65import java.util.ArrayList;
    76import java.util.Date;
     
    1514import org.openstreetmap.josm.data.projection.Projecting;
    1615import org.openstreetmap.josm.tools.Logging;
    17 import org.openstreetmap.josm.tools.UncheckedParseException;
    18 import org.openstreetmap.josm.tools.date.DateUtils;
    1916import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
    2017
     
    136133    public void setTime(Date time) {
    137134        this.time = time.getTime() / 1000.;
    138         this.attr.put(PT_TIME, DateUtils.fromDate(time));
     135        this.attr.put(PT_TIME, time);
    139136    }
    140137
     
    156153     */
    157154    public void setTime(long ts) {
    158         this.time = ts;
    159         this.attr.put(PT_TIME, DateUtils.fromTimestamp(ts));
     155        setTimeInMillis(ts*1000);
    160156    }
    161157
     
    168164    public void setTimeInMillis(long ts) {
    169165        this.time = ts / 1000.;
    170         this.attr.put(PT_TIME, DateUtils.fromTimestampInMillis(ts));
     166        this.attr.put(PT_TIME, new Date(ts));
    171167    }
    172168
     
    178174    public Date setTimeFromAttribute() {
    179175        if (attr.containsKey(PT_TIME)) {
    180             try {
    181                 final Object obj = get(PT_TIME);
    182                 final Date date = obj instanceof Date ? (Date) obj : DateUtils.fromString(obj.toString());
     176            final Object obj = get(PT_TIME);
     177            if (obj instanceof Date) {
     178                final Date date = (Date) obj;
    183179                time = date.getTime() / 1000.;
    184180                return date;
    185             } catch (UncheckedParseException | DateTimeException e) {
    186                 Logging.warn(e);
     181            } else {
     182                Logging.warn("Unsupported waypoint {0} value: {1}", PT_TIME, obj);
    187183                time = 0;
    188184            }
Note: See TracChangeset for help on using the changeset viewer.