diff --git a/src/org/openstreetmap/josm/tools/date/DateUtils.java b/src/org/openstreetmap/josm/tools/date/DateUtils.java
index c8a3245..7f6c19e 100644
|
a
|
b
|
|
| 4 | 4 | import java.text.DateFormat; |
| 5 | 5 | import java.text.ParsePosition; |
| 6 | 6 | import java.text.SimpleDateFormat; |
| | 7 | import java.time.ZoneId; |
| | 8 | import java.time.ZoneOffset; |
| | 9 | import java.time.ZonedDateTime; |
| | 10 | import java.time.temporal.ChronoField; |
| 7 | 11 | import java.util.Calendar; |
| 8 | 12 | import java.util.Date; |
| 9 | 13 | import java.util.GregorianCalendar; |
| … |
… |
public static synchronized long tsFromString(String str) {
|
| 96 | 100 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx") || |
| 97 | 101 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") || |
| 98 | 102 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) { |
| 99 | | final Calendar c; // consider EXIF date in default timezone |
| 100 | | if (checkLayout(str, "xxxx:xx:xx xx:xx:xx")) { |
| 101 | | c = getLocalCalendar(); |
| 102 | | } else { |
| 103 | | c = calendar; |
| 104 | | } |
| 105 | | c.set( |
| 106 | | parsePart4(str, 0), |
| 107 | | parsePart2(str, 5)-1, |
| 108 | | parsePart2(str, 8), |
| 109 | | parsePart2(str, 11), |
| 110 | | parsePart2(str, 14), |
| 111 | | parsePart2(str, 17)); |
| 112 | | c.set(Calendar.MILLISECOND, 0); |
| 113 | | |
| | 103 | final ZonedDateTime local = ZonedDateTime.of( |
| | 104 | parsePart4(str, 0), |
| | 105 | parsePart2(str, 5), |
| | 106 | parsePart2(str, 8), |
| | 107 | parsePart2(str, 11), |
| | 108 | parsePart2(str, 14), |
| | 109 | parsePart2(str, 17), |
| | 110 | 0, |
| | 111 | checkLayout(str, "xxxx:xx:xx xx:xx:xx") ? ZoneId.systemDefault() : ZoneOffset.UTC |
| | 112 | ); |
| 114 | 113 | if (str.length() == 22 || str.length() == 25) { |
| 115 | 114 | int plusHr = parsePart2(str, 20); |
| 116 | 115 | int mul = str.charAt(19) == '+' ? -3600000 : 3600000; |
| 117 | | return c.getTimeInMillis()+plusHr*mul; |
| | 116 | return local.with(ChronoField.MILLI_OF_SECOND, plusHr*mul).toInstant().toEpochMilli(); |
| 118 | 117 | } |
| 119 | 118 | |
| 120 | | return c.getTimeInMillis(); |
| | 119 | return local.toInstant().toEpochMilli(); |
| 121 | 120 | } else if (checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxxZ") || |
| 122 | 121 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") || |
| 123 | 122 | checkLayout(str, "xxxx:xx:xx xx:xx:xx.xxx") || |