### Eclipse Workspace Patch 1.0
#P JOSM
|
|
|
72 | 72 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") || |
73 | 73 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) { |
74 | 74 | calendar.set( |
75 | | parsePart(str, 0, 4), |
76 | | parsePart(str, 5, 2)-1, |
77 | | parsePart(str, 8, 2), |
78 | | parsePart(str, 11, 2), |
79 | | parsePart(str, 14, 2), |
80 | | parsePart(str, 17, 2)); |
| 75 | parsePart4(str, 0), |
| 76 | parsePart2(str, 5)-1, |
| 77 | parsePart2(str, 8), |
| 78 | parsePart2(str, 11), |
| 79 | parsePart2(str, 14), |
| 80 | parsePart2(str, 17)); |
81 | 81 | |
82 | 82 | if (str.length() == 25) { |
83 | | int plusHr = parsePart(str, 20, 2); |
| 83 | int plusHr = parsePart2(str, 20); |
84 | 84 | int mul = str.charAt(19) == '+' ? -3600000 : 3600000; |
85 | 85 | calendar.setTimeInMillis(calendar.getTimeInMillis()+plusHr*mul); |
86 | 86 | } |
… |
… |
|
91 | 91 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx+xx:00") || |
92 | 92 | checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx-xx:00")) { |
93 | 93 | calendar.set( |
94 | | parsePart(str, 0, 4), |
95 | | parsePart(str, 5, 2)-1, |
96 | | parsePart(str, 8, 2), |
97 | | parsePart(str, 11, 2), |
98 | | parsePart(str, 14, 2), |
99 | | parsePart(str, 17, 2)); |
100 | | long millis = parsePart(str, 20, 3); |
| 94 | parsePart4(str, 0), |
| 95 | parsePart2(str, 5)-1, |
| 96 | parsePart2(str, 8), |
| 97 | parsePart2(str, 11), |
| 98 | parsePart2(str, 14), |
| 99 | parsePart2(str, 17)); |
| 100 | long millis = parsePart3(str, 20); |
101 | 101 | if (str.length() == 29) |
102 | | millis += parsePart(str, 24, 2) * (str.charAt(23) == '+' ? -3600000 : 3600000); |
| 102 | millis += parsePart2(str, 24) * (str.charAt(23) == '+' ? -3600000 : 3600000); |
103 | 103 | calendar.setTimeInMillis(calendar.getTimeInMillis()+millis); |
104 | 104 | |
105 | 105 | return calendar.getTime(); |
… |
… |
|
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
144 | | private static int parsePart(String str, int off, int len) { |
145 | | return Integer.parseInt(str.substring(off, off+len)); |
| 144 | private static int parsePart2(String str, int off) { |
| 145 | return 10 * (str.charAt(off) - '0') + (str.charAt(off + 1) - '0'); |
146 | 146 | } |
147 | 147 | |
| 148 | private static int parsePart3(String str, int off) { |
| 149 | return 100 * (str.charAt(off) - '0') + 10 * (str.charAt(off + 1) - '0') + (str.charAt(off + 2) - '0'); |
| 150 | } |
| 151 | |
| 152 | private static int parsePart4(String str, int off) { |
| 153 | return 1000 * (str.charAt(off) - '0') + 100 * (str.charAt(off + 1) - '0') + 10 * (str.charAt(off + 2) - '0') + (str.charAt(off + 3) - '0'); |
| 154 | } |
| 155 | |
148 | 156 | /** |
149 | 157 | * Returns a new {@code SimpleDateFormat} for date only, according to <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>. |
150 | 158 | * @return a new ISO 8601 date format, for date only. |