@Test(expected = ParseException.class) public void testParse10() throws ParseException { ISO8601DateTime.fromISO8601DateTimeString("2018-10-11T22:12:44."); }
public static ISO8601DateTime fromISO8601DateTimeString(String strDateTime) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDateTime, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDateTime, 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 >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (month <= 0 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != 'T') { throw new ParseException("Missing time separator 'T'", startPos); } startPos++; int hours = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (hours < 0 || hours > 23) { throw new ParseException("Invalid hours", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int minutes = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (minutes < 0 || minutes > 59) { throw new ParseException("Invalid minutes", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int ss = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (ss < 0 || ss >= 60) { throw new ParseException("Invalid second of minute", startPos); } startPos += 2; int ms = 0; if (startPos < strDateTime.length() && strDateTime.charAt(startPos) == '.') { startPos++; if ((ms = ParseUtils.getThreeDigitValue(strDateTime, startPos)) < 0 || ms >= 1000) { throw new ParseException("Invalid milliseconds", startPos); } startPos += 3; } String timezone = null; if (startPos < strDateTime.length()) { switch(strDateTime.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDateTime.length()) { timezone = "GMT" + strDateTime.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601DateTime(timezone, year, month, day, hours, minutes, ss, ms); }
ISO8601DateTime implements IDateTime<ISO8601DateTime>, Comparable<ISO8601DateTime>, SemanticString { public static ISO8601DateTime fromISO8601DateTimeString(String strDateTime) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDateTime, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDateTime, 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 >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (month <= 0 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != 'T') { throw new ParseException("Missing time separator 'T'", startPos); } startPos++; int hours = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (hours < 0 || hours > 23) { throw new ParseException("Invalid hours", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int minutes = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (minutes < 0 || minutes > 59) { throw new ParseException("Invalid minutes", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int ss = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (ss < 0 || ss >= 60) { throw new ParseException("Invalid second of minute", startPos); } startPos += 2; int ms = 0; if (startPos < strDateTime.length() && strDateTime.charAt(startPos) == '.') { startPos++; if ((ms = ParseUtils.getThreeDigitValue(strDateTime, startPos)) < 0 || ms >= 1000) { throw new ParseException("Invalid milliseconds", startPos); } startPos += 3; } String timezone = null; if (startPos < strDateTime.length()) { switch(strDateTime.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDateTime.length()) { timezone = "GMT" + strDateTime.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601DateTime(timezone, year, month, day, hours, minutes, ss, ms); } }
ISO8601DateTime implements IDateTime<ISO8601DateTime>, Comparable<ISO8601DateTime>, SemanticString { public static ISO8601DateTime fromISO8601DateTimeString(String strDateTime) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDateTime, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDateTime, 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 >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (month <= 0 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != 'T') { throw new ParseException("Missing time separator 'T'", startPos); } startPos++; int hours = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (hours < 0 || hours > 23) { throw new ParseException("Invalid hours", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int minutes = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (minutes < 0 || minutes > 59) { throw new ParseException("Invalid minutes", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int ss = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (ss < 0 || ss >= 60) { throw new ParseException("Invalid second of minute", startPos); } startPos += 2; int ms = 0; if (startPos < strDateTime.length() && strDateTime.charAt(startPos) == '.') { startPos++; if ((ms = ParseUtils.getThreeDigitValue(strDateTime, startPos)) < 0 || ms >= 1000) { throw new ParseException("Invalid milliseconds", startPos); } startPos += 3; } String timezone = null; if (startPos < strDateTime.length()) { switch(strDateTime.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDateTime.length()) { timezone = "GMT" + strDateTime.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601DateTime(timezone, year, month, day, hours, minutes, ss, ms); } ISO8601DateTime(TimeZone timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(String timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(ISO8601TimeZone timeZone, ISO8601Date iso8601Date, ISO8601Time iso8601Time);  ISO8601DateTime(int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn); private  ISO8601DateTime(Calendar calendarIn, boolean hasTimeZoneIn); }
ISO8601DateTime implements IDateTime<ISO8601DateTime>, Comparable<ISO8601DateTime>, SemanticString { public static ISO8601DateTime fromISO8601DateTimeString(String strDateTime) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDateTime, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDateTime, 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 >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (month <= 0 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != 'T') { throw new ParseException("Missing time separator 'T'", startPos); } startPos++; int hours = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (hours < 0 || hours > 23) { throw new ParseException("Invalid hours", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int minutes = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (minutes < 0 || minutes > 59) { throw new ParseException("Invalid minutes", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int ss = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (ss < 0 || ss >= 60) { throw new ParseException("Invalid second of minute", startPos); } startPos += 2; int ms = 0; if (startPos < strDateTime.length() && strDateTime.charAt(startPos) == '.') { startPos++; if ((ms = ParseUtils.getThreeDigitValue(strDateTime, startPos)) < 0 || ms >= 1000) { throw new ParseException("Invalid milliseconds", startPos); } startPos += 3; } String timezone = null; if (startPos < strDateTime.length()) { switch(strDateTime.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDateTime.length()) { timezone = "GMT" + strDateTime.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601DateTime(timezone, year, month, day, hours, minutes, ss, ms); } ISO8601DateTime(TimeZone timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(String timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(ISO8601TimeZone timeZone, ISO8601Date iso8601Date, ISO8601Time iso8601Time);  ISO8601DateTime(int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn); private  ISO8601DateTime(Calendar calendarIn, boolean hasTimeZoneIn); boolean getHasTimeZone(); String getTimeZone(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinute(); int getSecond(); int getMillisecond(); Calendar getCalendar(); ISO8601DateTime getGMTDateTime(); ISO8601DateTime add(ISO8601Duration iso8601Duration); ISO8601DateTime sub(ISO8601Duration iso8601Duration); @Override int hashCode(); @Override boolean equals(Object obj); static ISO8601DateTime fromCalendar(Calendar calendar); static ISO8601DateTime fromDate(Date date); static ISO8601DateTime fromISO8601DateTimeString(String strDateTime); @Override String stringValue(); @Override String toString(); @Override int compareTo(ISO8601DateTime o); }
ISO8601DateTime implements IDateTime<ISO8601DateTime>, Comparable<ISO8601DateTime>, SemanticString { public static ISO8601DateTime fromISO8601DateTimeString(String strDateTime) throws ParseException { int startPos = ParseUtils.nextNonWhite(strDateTime, 0); ParseUtils.ParseValue<Integer> parseValue = ParseUtils.getSignedValue(strDateTime, 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 >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int month = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (month <= 0 || month > 12) { throw new ParseException("Invalid month", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != '-') { throw new ParseException("Invalid date", startPos); } startPos++; int day = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (day < 1 || day > 31) { throw new ParseException("Invalid day", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != 'T') { throw new ParseException("Missing time separator 'T'", startPos); } startPos++; int hours = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (hours < 0 || hours > 23) { throw new ParseException("Invalid hours", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int minutes = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (minutes < 0 || minutes > 59) { throw new ParseException("Invalid minutes", startPos); } startPos += 2; if (startPos >= strDateTime.length() || strDateTime.charAt(startPos) != ':') { throw new ParseException("Invalid date", startPos); } startPos++; int ss = ParseUtils.getTwoDigitValue(strDateTime, startPos); if (ss < 0 || ss >= 60) { throw new ParseException("Invalid second of minute", startPos); } startPos += 2; int ms = 0; if (startPos < strDateTime.length() && strDateTime.charAt(startPos) == '.') { startPos++; if ((ms = ParseUtils.getThreeDigitValue(strDateTime, startPos)) < 0 || ms >= 1000) { throw new ParseException("Invalid milliseconds", startPos); } startPos += 3; } String timezone = null; if (startPos < strDateTime.length()) { switch(strDateTime.charAt(startPos)) { case 'Z': timezone = "GMT"; break; case '-': case '+': if (startPos+5 < strDateTime.length()) { timezone = "GMT" + strDateTime.substring(startPos, startPos+6); } else { throw new ParseException("Invalid timezone", startPos); } break; default: throw new ParseException("Invalid timezone", startPos); } } return new ISO8601DateTime(timezone, year, month, day, hours, minutes, ss, ms); } ISO8601DateTime(TimeZone timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(String timeZone, int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn);  ISO8601DateTime(ISO8601TimeZone timeZone, ISO8601Date iso8601Date, ISO8601Time iso8601Time);  ISO8601DateTime(int yearIn, int monthIn, int dayIn, int hourIn, int minuteIn, int secondIn, int millisecondIn); private  ISO8601DateTime(Calendar calendarIn, boolean hasTimeZoneIn); boolean getHasTimeZone(); String getTimeZone(); int getYear(); int getMonth(); int getDay(); int getHour(); int getMinute(); int getSecond(); int getMillisecond(); Calendar getCalendar(); ISO8601DateTime getGMTDateTime(); ISO8601DateTime add(ISO8601Duration iso8601Duration); ISO8601DateTime sub(ISO8601Duration iso8601Duration); @Override int hashCode(); @Override boolean equals(Object obj); static ISO8601DateTime fromCalendar(Calendar calendar); static ISO8601DateTime fromDate(Date date); static ISO8601DateTime fromISO8601DateTimeString(String strDateTime); @Override String stringValue(); @Override String toString(); @Override int compareTo(ISO8601DateTime o);  }