@Test(expected = ParseException.class) public void testParse4() throws ParseException { ISO8601Date.fromISO8601DateString("2007-32-05"); }
public static ISO8601Date fromISO8601DateString(String strDate) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDate, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDate, startPos); if (parseValue == null) { throw new ParseException("Invalid year", startPos); } int year = parseValue.getValue(); if (parseValue.getNextPos() < 4) { throw new ParseException("Invalid year (must be at least 4 digits)", startPos); } startPos += parseValue.getNextPos(); if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDate, startPos); if (month < 1 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDate, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; String timezone = null; if (startPos < strDate.length()) { switch(strDate.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDate.length()) { timezone = "GMT" + strDate.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601Date(timezone, year, month, day); }
ISO8601Date implements IDateTime<ISO8601Date>, Comparable<ISO8601Date>, SemanticString { public static ISO8601Date fromISO8601DateString(String strDate) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDate, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDate, startPos); if (parseValue == null) { throw new ParseException("Invalid year", startPos); } int year = parseValue.getValue(); if (parseValue.getNextPos() < 4) { throw new ParseException("Invalid year (must be at least 4 digits)", startPos); } startPos += parseValue.getNextPos(); if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDate, startPos); if (month < 1 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDate, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; String timezone = null; if (startPos < strDate.length()) { switch(strDate.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDate.length()) { timezone = "GMT" + strDate.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601Date(timezone, year, month, day); } }
ISO8601Date implements IDateTime<ISO8601Date>, Comparable<ISO8601Date>, SemanticString { public static ISO8601Date fromISO8601DateString(String strDate) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDate, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDate, startPos); if (parseValue == null) { throw new ParseException("Invalid year", startPos); } int year = parseValue.getValue(); if (parseValue.getNextPos() < 4) { throw new ParseException("Invalid year (must be at least 4 digits)", startPos); } startPos += parseValue.getNextPos(); if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDate, startPos); if (month < 1 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDate, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; String timezone = null; if (startPos < strDate.length()) { switch(strDate.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDate.length()) { timezone = "GMT" + strDate.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601Date(timezone, year, month, day); } ISO8601Date(ISO8601DateTime iso8601DateTime);  ISO8601Date(String timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(ISO8601TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(int yearIn, int monthIn, int dayIn); }
ISO8601Date implements IDateTime<ISO8601Date>, Comparable<ISO8601Date>, SemanticString { public static ISO8601Date fromISO8601DateString(String strDate) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDate, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDate, startPos); if (parseValue == null) { throw new ParseException("Invalid year", startPos); } int year = parseValue.getValue(); if (parseValue.getNextPos() < 4) { throw new ParseException("Invalid year (must be at least 4 digits)", startPos); } startPos += parseValue.getNextPos(); if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDate, startPos); if (month < 1 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDate, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; String timezone = null; if (startPos < strDate.length()) { switch(strDate.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDate.length()) { timezone = "GMT" + strDate.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601Date(timezone, year, month, day); } ISO8601Date(ISO8601DateTime iso8601DateTime);  ISO8601Date(String timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(ISO8601TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(int yearIn, int monthIn, int dayIn); boolean getHasTimeZone(); Calendar getCalendar(); String getTimeZone(); int getYear(); int getMonth(); int getDay(); ISO8601Date add(ISO8601Duration iso8601Duration); ISO8601Date sub(ISO8601Duration iso8601Duration); @Override int hashCode(); @Override boolean equals(Object obj); String stringValue(boolean includeTimeZone); @Override String stringValue(); @Override String toString(); @Override int compareTo(ISO8601Date o); static ISO8601Date fromCalendar(Calendar calendar); static ISO8601Date fromDate(Date date); static ISO8601Date fromISO8601DateString(String strDate); }
ISO8601Date implements IDateTime<ISO8601Date>, Comparable<ISO8601Date>, SemanticString { public static ISO8601Date fromISO8601DateString(String strDate) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDate, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDate, startPos); if (parseValue == null) { throw new ParseException("Invalid year", startPos); } int year = parseValue.getValue(); if (parseValue.getNextPos() < 4) { throw new ParseException("Invalid year (must be at least 4 digits)", startPos); } startPos += parseValue.getNextPos(); if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDate, startPos); if (month < 1 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDate.length() || strDate.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDate, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; String timezone = null; if (startPos < strDate.length()) { switch(strDate.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDate.length()) { timezone = "GMT" + strDate.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601Date(timezone, year, month, day); } ISO8601Date(ISO8601DateTime iso8601DateTime);  ISO8601Date(String timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(ISO8601TimeZone timeZone, int yearIn, int monthIn, int dayIn);  ISO8601Date(int yearIn, int monthIn, int dayIn); boolean getHasTimeZone(); Calendar getCalendar(); String getTimeZone(); int getYear(); int getMonth(); int getDay(); ISO8601Date add(ISO8601Duration iso8601Duration); ISO8601Date sub(ISO8601Duration iso8601Duration); @Override int hashCode(); @Override boolean equals(Object obj); String stringValue(boolean includeTimeZone); @Override String stringValue(); @Override String toString(); @Override int compareTo(ISO8601Date o); static ISO8601Date fromCalendar(Calendar calendar); static ISO8601Date fromDate(Date date); static ISO8601Date fromISO8601DateString(String strDate);  }