/** * Verify that input values are within specified bounds. * * @param value the value to check * @param lowerBound the lower bound allowed for value * @param upperBound the upper bound allowed for value * @throws IllegalFieldValueException if value is not in the specified bounds */ public static void verifyValueBounds(String fieldName, int value, int lowerBound, int upperBound) { if ((value < lowerBound) || (value > upperBound)) { throw new IllegalFieldValueException (fieldName, Integer.valueOf(value), Integer.valueOf(lowerBound), Integer.valueOf(upperBound)); } }
public int monthOfYearTextToValue(String text) { Integer month = iParseMonths.get(text); if (month != null) { return month.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.monthOfYear(), text); }
static int adjustYearForSet(int year) { if (year <= 0) { if (year == 0) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(year), null, null); } year++; } return year; }
public int eraTextToValue(String text) { Integer era = iParseEras.get(text); if (era != null) { return era.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.era(), text); }
/** @inheritDoc */ public long set(long instant, String text, Locale locale) { if (iEraText.equals(text) == false && "1".equals(text) == false) { throw new IllegalFieldValueException(DateTimeFieldType.era(), text); } return instant; }
public int halfdayTextToValue(String text) { String[] halfday = iHalfday; for (int i = halfday.length; --i>=0; ) { if (halfday[i].equalsIgnoreCase(text)) { return i; } } throw new IllegalFieldValueException(DateTimeFieldType.halfdayOfDay(), text); }
public int dayOfWeekTextToValue(String text) { Integer day = iParseDaysOfWeek.get(text); if (day != null) { return day.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.dayOfWeek(), text); }
static int adjustYearForSet(int year) { if (year <= 0) { if (year == 0) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(year), null, null); } year++; } return year; }
public int eraTextToValue(String text) { Integer era = iParseEras.get(text); if (era != null) { return era.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.era(), text); }
/** @inheritDoc */ public long set(long instant, String text, Locale locale) { if (iEraText.equals(text) == false && "1".equals(text) == false) { throw new IllegalFieldValueException(DateTimeFieldType.era(), text); } return instant; }
public int halfdayTextToValue(String text) { String[] halfday = iHalfday; for (int i = halfday.length; --i>=0; ) { if (halfday[i].equalsIgnoreCase(text)) { return i; } } throw new IllegalFieldValueException(DateTimeFieldType.halfdayOfDay(), text); }
public int monthOfYearTextToValue(String text) { Integer month = iParseMonths.get(text); if (month != null) { return month.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.monthOfYear(), text); }
public int dayOfWeekTextToValue(String text) { Integer day = iParseDaysOfWeek.get(text); if (day != null) { return day.intValue(); } throw new IllegalFieldValueException(DateTimeFieldType.dayOfWeek(), text); }
/** * Convert the specified text and locale into a value. * * @param text the text to convert * @param locale the locale to convert using * @return the value extracted from the text * @throws IllegalArgumentException if the text is invalid */ protected int convertText(String text, Locale locale) { try { return Integer.parseInt(text); } catch (NumberFormatException ex) { throw new IllegalFieldValueException(getType(), text); } }
/** * Verify that input values are within specified bounds. * * @param value the value to check * @param lowerBound the lower bound allowed for value * @param upperBound the upper bound allowed for value * @throws IllegalFieldValueException if value is not in the specified bounds */ public static void verifyValueBounds(DateTimeField field, int value, int lowerBound, int upperBound) { if ((value < lowerBound) || (value > upperBound)) { throw new IllegalFieldValueException (field.getType(), Integer.valueOf(value), Integer.valueOf(lowerBound), Integer.valueOf(upperBound)); } }
/** * Convert the specified text and locale into a value. * * @param text the text to convert * @param locale the locale to convert using * @return the value extracted from the text * @throws IllegalArgumentException if the text is invalid */ protected int convertText(String text, Locale locale) { try { return Integer.parseInt(text); } catch (NumberFormatException ex) { throw new IllegalFieldValueException(getType(), text); } }
public long set(long millis, int value) { FieldUtils.verifyValueBounds(this, value, iMinValue, getMaximumValue()); if (value <= iSkip) { if (value == iSkip) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(value), null, null); } value++; } return super.set(millis, value); }
public long set(long millis, int value) { FieldUtils.verifyValueBounds(this, value, iMinValue, getMaximumValue()); if (value <= iSkip) { if (value == iSkip) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(value), null, null); } value++; } return super.set(millis, value); }
public long set(long instant, int value) { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, value); long result = iZone.convertLocalToUTC(localInstant, false, instant); if (get(result) != value) { IllegalInstantException cause = new IllegalInstantException(localInstant, iZone.getID()); IllegalFieldValueException ex = new IllegalFieldValueException(iField.getType(), Integer.valueOf(value), cause.getMessage()); ex.initCause(cause); throw ex; } return result; }
public long set(long instant, int value) { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, value); long result = iZone.convertLocalToUTC(localInstant, false, instant); if (get(result) != value) { IllegalInstantException cause = new IllegalInstantException(localInstant, iZone.getID()); IllegalFieldValueException ex = new IllegalFieldValueException(iField.getType(), Integer.valueOf(value), cause.getMessage()); ex.initCause(cause); throw ex; } return result; }