Changeset 17839 in josm for trunk/src/org
- Timestamp:
- 2021-05-01T12:37:41+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/rtklib/RtkLibPosReader.java
r17787 r17839 7 7 import java.io.InputStreamReader; 8 8 import java.nio.charset.StandardCharsets; 9 import java.text.ParseException;10 import java.text.SimpleDateFormat;11 9 import java.util.ArrayList; 12 10 import java.util.Collection; 13 11 import java.util.Collections; 14 import java.util.Date;15 import java.util.Locale;16 12 import java.util.Objects; 17 13 … … 50 46 private static final int IDX_RATIO = 14; 51 47 52 private final SimpleDateFormat dateTimeFmtS = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ENGLISH); // 2019/06/08 08:23:1553 private final SimpleDateFormat dateTimeFmtL = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS", Locale.ENGLISH); // 2019/06/08 08:23:15.00054 55 48 private final InputStream source; 56 49 private GpxData data; … … 64 57 public RtkLibPosReader(InputStream source) throws IOException { 65 58 this.source = Objects.requireNonNull(source); 66 dateTimeFmtS.setTimeZone(DateUtils.UTC);67 dateTimeFmtL.setTimeZone(DateUtils.UTC);68 }69 70 private Date parseDate(String date) throws ParseException {71 return (date.length() > 20 ? dateTimeFmtL : dateTimeFmtS).parse(date);72 59 } 73 60 … … 91 78 Double.parseDouble(fields[IDX_LON]))); 92 79 currentwp.put(GpxConstants.PT_ELE, fields[IDX_HEIGHT]); 93 currentwp.setInstant( parseDate(fields[IDX_DATE]+" "+fields[IDX_TIME]).toInstant());80 currentwp.setInstant(DateUtils.parseInstant(fields[IDX_DATE]+" "+fields[IDX_TIME])); 94 81 currentwp.put(GpxConstants.RTKLIB_Q, Integer.parseInt(fields[IDX_Q])); 95 82 currentwp.put(GpxConstants.PT_SAT, fields[IDX_NS]); … … 107 94 waypoints.add(currentwp); 108 95 success++; 109 } catch ( ParseException |IllegalArgumentException e) {96 } catch (IllegalArgumentException e) { 110 97 Logging.error(e); 111 98 } -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r17715 r17839 91 91 checkLayout(str, "xxxx-xx-xxTxx:xx:xx") || 92 92 checkLayout(str, "xxxx:xx:xx xx:xx:xx") || 93 checkLayout(str, "xxxx/xx/xx xx:xx:xx") || 93 94 checkLayout(str, "xxxx-xx-xx xx:xx:xxZ") || 94 95 checkLayout(str, "xxxx-xx-xx xx:xx:xx UTC") || … … 115 116 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") || 116 117 checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") || 118 checkLayout(str, "xxxx/xx/xx xx:xx:xx.xxx") || 117 119 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx+xx:00") || 118 120 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx-xx:00")) {
Note:
See TracChangeset
for help on using the changeset viewer.