year = -year + (xsMode ? 0 : 1); if (year == 0) { throw new DateParseException(MSG_YEAR_0_NOT_ALLOWED); throw new DateParseException( "Hour 24 is only allowed in the case of " + "midnight."); } catch (IllegalArgumentException e) { throw new DateParseException( "Date-time calculation faliure. " + "Probably the date-time is formally correct, but "
year = -year + (xsMode ? 0 : 1); if (year == 0) { throw new DateParseException(MSG_YEAR_0_NOT_ALLOWED); throw new DateParseException( "Hour 24 is only allowed in the case of " + "midnight."); } catch (IllegalArgumentException e) { throw new DateParseException( "Date-time calculation faliure. " + "Probably the date-time is formally correct, but "
year = -year + (xsMode ? 0 : 1); if (year == 0) { throw new DateParseException(MSG_YEAR_0_NOT_ALLOWED); throw new DateParseException( "Hour 24 is only allowed in the case of " + "midnight."); } catch (IllegalArgumentException e) { throw new DateParseException( "Date-time calculation faliure. " + "Probably the date-time is formally correct, but "
throws DateParseException { if (g == null) { throw new DateParseException("The " + gName + " part " + "is missing."); throw new DateParseException("The " + gName + " part " + "must be at least " + min + "."); throw new DateParseException("The " + gName + " part " + "can't be more than " + max + "."); throw new DateParseException("The " + gName + " part " + "is a malformed integer.");
throws DateParseException { if (g == null) { throw new DateParseException("The " + gName + " part " + "is missing."); throw new DateParseException("The " + gName + " part " + "must be at least " + min + "."); throw new DateParseException("The " + gName + " part " + "can't be more than " + max + "."); throw new DateParseException("The " + gName + " part " + "is a malformed integer.");
day = 2; } else { throw new DateParseException( "Hour 24 is only allowed in the case of " + "midnight."); } catch (IllegalArgumentException e) { throw new DateParseException( "Unexpected time calculation faliure.");
day = 2; } else { throw new DateParseException( "Hour 24 is only allowed in the case of " + "midnight."); } catch (IllegalArgumentException e) { throw new DateParseException( "Unexpected time calculation faliure.");
year = -year + (xsMode ? 0 : 1); if (year == 0) { throw new DateParseException(MSG_YEAR_0_NOT_ALLOWED); } catch (IllegalArgumentException e) { throw new DateParseException( "Date calculation faliure. " + "Probably the date is formally correct, but refers "
year = -year + (xsMode ? 0 : 1); if (year == 0) { throw new DateParseException(MSG_YEAR_0_NOT_ALLOWED); } catch (IllegalArgumentException e) { throw new DateParseException( "Date calculation faliure. " + "Probably the date is formally correct, but refers "
/** * Parses an W3C XML Schema date string (not time or date-time). * Unlike in ISO 8601:2000 Second Edition, year -1 means B.C 1, and year 0 is invalid. * * @param dateStr the string to parse. * @param defaultTimeZone used if the date doesn't specify the * time zone offset explicitly. Can't be {@code null}. * @param calToDateConverter Used internally to calculate the result from the calendar field values. * If you don't have a such object around, you can just use * {@code new }{@link TrivialCalendarFieldsToDateConverter}{@code ()}. * * @throws DateParseException if the date is malformed, or if the time * zone offset is unspecified and the {@code defaultTimeZone} is * {@code null}. */ public static Date parseXSDate( String dateStr, TimeZone defaultTimeZone, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_XS_DATE.matcher(dateStr); if (!m.matches()) { throw new DateParseException("The value didn't match the expected pattern: " + PATTERN_XS_DATE); } return parseDate_parseMatcher( m, defaultTimeZone, true, calToDateConverter); }
/** * Parses an W3C XML Schema date string (not time or date-time). * Unlike in ISO 8601:2000 Second Edition, year -1 means B.C 1, and year 0 is invalid. * * @param dateStr the string to parse. * @param defaultTimeZone used if the date doesn't specify the * time zone offset explicitly. Can't be {@code null}. * @param calToDateConverter Used internally to calculate the result from the calendar field values. * If you don't have a such object around, you can just use * {@code new }{@link TrivialCalendarFieldsToDateConverter}{@code ()}. * * @throws DateParseException if the date is malformed, or if the time * zone offset is unspecified and the {@code defaultTimeZone} is * {@code null}. */ public static Date parseXSDate( String dateStr, TimeZone defaultTimeZone, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_XS_DATE.matcher(dateStr); if (!m.matches()) { throw new DateParseException("The value didn't match the expected pattern: " + PATTERN_XS_DATE); } return parseDate_parseMatcher( m, defaultTimeZone, true, calToDateConverter); }
/** * Parses an W3C XML Schema date-time string (not date or time). * Unlike in ISO 8601:2000 Second Edition, year -1 means B.C 1, and year 0 is invalid. * * @param dateTimeStr the string to parse. * @param defaultTZ used if the dateTime doesn't specify the * time zone offset explicitly. Can't be {@code null}. * * @throws DateParseException if the dateTime is malformed. */ public static Date parseXSDateTime( String dateTimeStr, TimeZone defaultTZ, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_XS_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { throw new DateParseException( "The value didn't match the expected pattern: " + PATTERN_XS_DATE_TIME); } return parseDateTime_parseMatcher( m, defaultTZ, true, calToDateConverter); }
/** * Parses an W3C XML Schema date-time string (not date or time). * Unlike in ISO 8601:2000 Second Edition, year -1 means B.C 1, and year 0 is invalid. * * @param dateTimeStr the string to parse. * @param defaultTZ used if the dateTime doesn't specify the * time zone offset explicitly. Can't be {@code null}. * * @throws DateParseException if the dateTime is malformed. */ public static Date parseXSDateTime( String dateTimeStr, TimeZone defaultTZ, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_XS_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { throw new DateParseException( "The value didn't match the expected pattern: " + PATTERN_XS_DATE_TIME); } return parseDateTime_parseMatcher( m, defaultTZ, true, calToDateConverter); }
@Override @SuppressFBWarnings(value = "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN", justification = "Known to use the singleton Boolean-s only") public final Date parse(String s, int dateType) throws UnparsableValueException { CalendarFieldsToDateConverter calToDateConverter = factory.getCalendarFieldsToDateCalculator(env); TimeZone tz = forceUTC != Boolean.FALSE ? DateUtil.UTC : timeZone; try { if (dateType == TemplateDateModel.DATE) { return parseDate(s, tz, calToDateConverter); } else if (dateType == TemplateDateModel.TIME) { return parseTime(s, tz, calToDateConverter); } else if (dateType == TemplateDateModel.DATETIME) { return parseDateTime(s, tz, calToDateConverter); } else { throw new BugException("Unexpected date type: " + dateType); } } catch (DateParseException e) { throw new UnparsableValueException(e.getMessage(), e); } }
@Override @SuppressFBWarnings(value = "RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN", justification = "Known to use the singleton Boolean-s only") public final Date parse(String s, int dateType) throws UnparsableValueException { CalendarFieldsToDateConverter calToDateConverter = factory.getCalendarFieldsToDateCalculator(env); TimeZone tz = forceUTC != Boolean.FALSE ? DateUtil.UTC : timeZone; try { if (dateType == TemplateDateModel.DATE) { return parseDate(s, tz, calToDateConverter); } else if (dateType == TemplateDateModel.TIME) { return parseTime(s, tz, calToDateConverter); } else if (dateType == TemplateDateModel.DATETIME) { return parseDateTime(s, tz, calToDateConverter); } else { throw new BugException("Unexpected date type: " + dateType); } } catch (DateParseException e) { throw new UnparsableValueException(e.getMessage(), e); } }
/** * Same as {@link #parseXSDate(String, TimeZone, CalendarFieldsToDateConverter)}, but for ISO 8601 dates. */ public static Date parseISO8601Date( String dateStr, TimeZone defaultTimeZone, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_ISO8601_EXTENDED_DATE.matcher(dateStr); if (!m.matches()) { m = PATTERN_ISO8601_BASIC_DATE.matcher(dateStr); if (!m.matches()) { throw new DateParseException("The value didn't match the expected pattern: " + PATTERN_ISO8601_EXTENDED_DATE + " or " + PATTERN_ISO8601_BASIC_DATE); } } return parseDate_parseMatcher( m, defaultTimeZone, false, calToDateConverter); }
/** * Same as {@link #parseXSDate(String, TimeZone, CalendarFieldsToDateConverter)}, but for ISO 8601 dates. */ public static Date parseISO8601Date( String dateStr, TimeZone defaultTimeZone, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_ISO8601_EXTENDED_DATE.matcher(dateStr); if (!m.matches()) { m = PATTERN_ISO8601_BASIC_DATE.matcher(dateStr); if (!m.matches()) { throw new DateParseException("The value didn't match the expected pattern: " + PATTERN_ISO8601_EXTENDED_DATE + " or " + PATTERN_ISO8601_BASIC_DATE); } } return parseDate_parseMatcher( m, defaultTimeZone, false, calToDateConverter); }
/** * Same as {@link #parseXSTime(String, TimeZone, CalendarFieldsToDateConverter)} but for ISO 8601 times. */ public static Date parseISO8601Time( String timeStr, TimeZone defaultTZ, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_ISO8601_EXTENDED_TIME.matcher(timeStr); if (!m.matches()) { m = PATTERN_ISO8601_BASIC_TIME.matcher(timeStr); if (!m.matches()) { throw new DateParseException("The value didn't match the expected pattern: " + PATTERN_ISO8601_EXTENDED_TIME + " or " + PATTERN_ISO8601_BASIC_TIME); } } return parseTime_parseMatcher(m, defaultTZ, calToDateConverter); }
/** * Same as {@link #parseXSDateTime(String, TimeZone, CalendarFieldsToDateConverter)} but for ISO 8601 format. */ public static Date parseISO8601DateTime( String dateTimeStr, TimeZone defaultTZ, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_ISO8601_EXTENDED_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { m = PATTERN_ISO8601_BASIC_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { throw new DateParseException("The value (" + dateTimeStr + ") didn't match the expected pattern: " + PATTERN_ISO8601_EXTENDED_DATE_TIME + " or " + PATTERN_ISO8601_BASIC_DATE_TIME); } } return parseDateTime_parseMatcher( m, defaultTZ, false, calToDateConverter); }
/** * Same as {@link #parseXSDateTime(String, TimeZone, CalendarFieldsToDateConverter)} but for ISO 8601 format. */ public static Date parseISO8601DateTime( String dateTimeStr, TimeZone defaultTZ, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { Matcher m = PATTERN_ISO8601_EXTENDED_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { m = PATTERN_ISO8601_BASIC_DATE_TIME.matcher(dateTimeStr); if (!m.matches()) { throw new DateParseException("The value (" + dateTimeStr + ") didn't match the expected pattern: " + PATTERN_ISO8601_EXTENDED_DATE_TIME + " or " + PATTERN_ISO8601_BASIC_DATE_TIME); } } return parseDateTime_parseMatcher( m, defaultTZ, false, calToDateConverter); }