Ignore:
Timestamp:
2016-01-10T13:04:06+01:00 (4 years ago)
Author:
simon04
Message:

Deprecate PrimaryDateParser in favour of DateUtils

File:
1 edited

Legend:

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

    r8846 r9383  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.data.projection.Projections;
    14 import org.openstreetmap.josm.tools.date.PrimaryDateParser;
     14import org.openstreetmap.josm.tools.date.DateUtils;
    1515import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
    1616
    1717public class WayPoint extends WithAttributes implements Comparable<WayPoint>, TemplateEngineDataProvider {
    18 
    19     private static ThreadLocal<PrimaryDateParser> dateParser = new ThreadLocal<PrimaryDateParser>() {
    20         @Override protected PrimaryDateParser initialValue() {
    21             return new PrimaryDateParser();
    22         }
    23     };
    2418
    2519    public double time;
     
    9993
    10094    /**
     95     * Sets the {@link #time} field as well as the {@link #PT_TIME} attribute to the specified time
     96     *
     97     * @param time the time to set
     98     * @since 9383
     99     */
     100    public void setTime(Date time) {
     101        this.time = time.getTime() / 1000.;
     102        this.attr.put(PT_TIME, DateUtils.fromDate(time));
     103    }
     104
     105    /**
    101106     * Convert the time stamp of the waypoint into seconds from the epoch
    102107     */
    103108    public void setTime() {
     109        setTimeFromAttribute();
     110    }
     111
     112    /**
     113     * Convert the time stamp of the waypoint into seconds from the epoch
     114     * @return The parsed time if successful, or {@code null}
     115     * @since 9383
     116     */
     117    public Date setTimeFromAttribute() {
    104118        if (attr.containsKey(PT_TIME)) {
    105119            try {
    106                 time = dateParser.get().parse(get(PT_TIME).toString()).getTime() / 1000.; /* ms => seconds */
     120                final Date time = DateUtils.fromString(get(PT_TIME).toString());
     121                setTime(time);
     122                return time;
    107123            } catch (Exception e) {
     124                Main.warn(e);
    108125                time = 0;
    109126            }
    110127        }
     128        return null;
    111129    }
    112130
Note: See TracChangeset for help on using the changeset viewer.