| 87 | } |
| 88 | |
| 89 | private static int parseField(String text, int offset, int length, Calendar calendar, int field, int adjustment) throws ParseException { |
| 90 | if (text.length() < offset + length) throw new ParseException("Short date: " + text, offset); |
| 91 | try { |
| 92 | int value = Integer.parseInt(text.substring(offset, offset + length), 10); |
| 93 | calendar.set(field, value + adjustment); |
| 94 | } catch (NumberFormatException e) { |
| 95 | throw new ParseException("Not a number: " + text, offset); |
| 96 | } |
| 97 | return offset + length; |
| 98 | } |
| 99 | |
| 100 | private static int expectPrefix(String text, int offset, String prefix) throws ParseException { |
| 101 | if (text.length() <= offset) throw new ParseException("Short date: " + text, offset); |