Changeset 8564 in josm for trunk/src/org
- Timestamp:
- 2015-07-04T17:42:07+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r8510 r8564 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); … … 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 … … 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 num(char c) { 145 return c - '0'; 146 } 147 148 private static int parsePart2(String str, int off) { 149 return 10 * num(str.charAt(off)) + num(str.charAt(off + 1)); 150 } 151 152 private static int parsePart3(String str, int off) { 153 return 100 * num(str.charAt(off)) + 10 * num(str.charAt(off + 1)) + num(str.charAt(off + 2)); 154 } 155 156 private static int parsePart4(String str, int off) { 157 return 1000 * num(str.charAt(off)) + 100 * num(str.charAt(off + 1)) + 10 * num(str.charAt(off + 2)) + num(str.charAt(off + 3)); 146 158 } 147 159
Note:
See TracChangeset
for help on using the changeset viewer.