Changeset 17987 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r17911 r17987 136 136 } 137 137 return local.toInstant(); 138 } else if (checkLayout(str, "xxxx/xx/xx xx:xx:xx.xxxxxx")) { 139 return ZonedDateTime.of( 140 parsePart4(str, 0), 141 parsePart2(str, 5), 142 parsePart2(str, 8), 143 parsePart2(str, 11), 144 parsePart2(str, 14), 145 parsePart2(str, 17), 146 parsePart6(str, 20) * 1_000, 147 ZoneOffset.UTC 148 ).toInstant(); 138 149 } else { 139 150 // example date format "18-AUG-08 13:33:03" … … 232 243 } 233 244 245 private static int parsePart6(String str, int off) { 246 return 100000 * num(str.charAt(off)) 247 + 10000 * num(str.charAt(off + 1)) 248 + 1000 * num(str.charAt(off + 2)) 249 + 100 * num(str.charAt(off + 3)) 250 + 10 * num(str.charAt(off + 4)) 251 + num(str.charAt(off + 5)); 252 } 253 234 254 /** 235 255 * Returns a new {@code SimpleDateFormat} for date only, according to <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>. -
trunk/test/unit/org/openstreetmap/josm/io/rtklib/RtkLibPosReaderTest.java
r17715 r17987 76 76 assertEquals(6, in.getNumberOfCoordinates()); 77 77 } 78 79 /** 80 * Tests reading another RTKLib pos file with yet another different date format. 81 * @throws Exception if any error occurs 82 */ 83 @Test 84 void testReader3() throws Exception { 85 RtkLibPosReader in = read("nodist/data/rtklib_example3.pos"); 86 assertEquals(1, in.getNumberOfCoordinates()); 87 } 78 88 } -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r17912 r17987 103 103 assertEquals(481161600000L, DateUtils.fromString("1985-04").getTime()); 104 104 assertEquals(473385600000L, DateUtils.fromString("1985").getTime()); 105 } 106 107 @Test 108 void testRtklib() { 109 // examples taken from rtklib .pos files 110 assertEquals("2019-04-21T08:20:32Z", DateUtils.parseInstant("2019/04/21 08:20:32").toString()); 111 assertEquals("2019-06-08T08:23:12.123Z", DateUtils.parseInstant("2019/06/08 08:23:12.123").toString()); 112 assertEquals("2021-03-30T15:04:01.123456Z", DateUtils.parseInstant("2021/03/30 15:04:01.123456").toString()); 105 113 } 106 114
Note:
See TracChangeset
for help on using the changeset viewer.