Changeset 9383 in josm for trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
- Timestamp:
- 2016-01-10T13:04:06+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r8846 r9383 12 12 import org.openstreetmap.josm.data.coor.LatLon; 13 13 import org.openstreetmap.josm.data.projection.Projections; 14 import org.openstreetmap.josm.tools.date. PrimaryDateParser;14 import org.openstreetmap.josm.tools.date.DateUtils; 15 15 import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider; 16 16 17 17 public 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 };24 18 25 19 public double time; … … 99 93 100 94 /** 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 /** 101 106 * Convert the time stamp of the waypoint into seconds from the epoch 102 107 */ 103 108 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() { 104 118 if (attr.containsKey(PT_TIME)) { 105 119 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; 107 123 } catch (Exception e) { 124 Main.warn(e); 108 125 time = 0; 109 126 } 110 127 } 128 return null; 111 129 } 112 130
Note:
See TracChangeset
for help on using the changeset viewer.