Java 类org.joda.time.IllegalFieldValueException 实例源码

项目:rpsl4j-parser    文件:Changed.java   
public static Changed parse(final String value) {
    if (value.length() > MAX_LENGTH) {
        throw new AttributeParseException("Too long", value);
    }

    final Matcher matcher = CHANGED_PATTERN.matcher(value);
    if (!matcher.matches()) {
        throw new AttributeParseException("Invalid syntax", value);
    }

    final String email = matcher.group(1).trim();
    final String dateString = matcher.group(2);
    final LocalDate date;

    if (dateString == null) {
        date = null;
    } else {
        try {
            date = CHANGED_ATTRIBUTE_DATE_FORMAT.parseLocalDate(dateString);
        } catch (IllegalFieldValueException e) {
            throw new AttributeParseException("Invalid date: " + dateString, value);
        }
    }

    return new Changed(email, date);
}
项目:whois    文件:Changed.java   
public static Changed parse(final String value) {
    if (value.length() > MAX_LENGTH) {
        throw new AttributeParseException("Too long", value);
    }

    final Matcher matcher = CHANGED_PATTERN.matcher(value);
    if (!matcher.matches()) {
        throw new AttributeParseException("Invalid syntax", value);
    }

    final String email = matcher.group(1).trim();
    final String dateString = matcher.group(2);
    final LocalDate date;

    if (dateString == null) {
        date = null;
    } else {
        try {
            date = CHANGED_ATTRIBUTE_DATE_FORMAT.parseLocalDate(dateString);
        } catch (IllegalFieldValueException e) {
            throw new AttributeParseException("Invalid date: " + dateString, value);
        }
    }

    return new Changed(email, date);
}
项目:autorest.java    文件:DatetimeOperationsTests.java   
@Test
public void getUnderflowDate() throws Exception {
    try {
        client.datetimes().getUnderflow();
        Assert.assertTrue(false);
    } catch (Exception exception) {
        // expected
        Assert.assertEquals(IllegalFieldValueException.class, exception.getClass());
     }
}
项目:autorest.java    文件:DateOperationsTests.java   
@Test
public void getUnderflowDate() throws Exception {
    try {
        client.dates().getUnderflowDate();
        Assert.assertTrue(false);
    } catch (Exception exception) {
        // expected
        Assert.assertEquals(IllegalFieldValueException.class, exception.getClass());
    }
}
项目:ibm-cos-sdk-java    文件:DateUtilsTest.java   
@Test(expected=IllegalFieldValueException.class)
public void testIssue233JodaTimeLimit() throws ParseException {
    // https://github.com/aws/aws-sdk-java/issues/233
    String s = DateUtils.iso8601DateFormat.print(Long.MAX_VALUE);
    System.out.println("s: " + s);
    try {
        DateTime dt = DateUtils.iso8601DateFormat.parseDateTime(s);
        fail("Unexpected success: " + dt);
    } catch(IllegalFieldValueException ex) {
        // expected
        throw ex;
    }
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaAll()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( 0, 0, 0, 0, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaDayHourMinute()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( 1, 1, -1, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaHourMinute()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( 1, 1, 1, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaMinute()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( 1, 1, 1, 1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaMonthDayHourMinute()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( 1, -1, -1, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaYear()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( -1, 0, 0, 0, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaYearMonth()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( -1, -1, 0, 0, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaYearMonthDay()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( -1, -1, -1, 0, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaYearMonthDayHour()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( -1, -1, -1, -1, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDateHourFalhaYearMonthDayHourMinute()
{
    // Fixture Setup, DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour)

    // Exercise SUT
    final DateTime DateHour = new DateTime( -1, -1, -1, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaDayNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( 2017, 12, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaMonthDayNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( 0, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaMonthNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( 2017, -1, 1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaYearMontDayNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( -1, -1, -1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaYearMonthNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( -1, -1, 1 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeDateFalhaYearNegative()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate natal2017 = new LocalDate( -20, 1, 0 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void creationDeHoursFalha()
{
    // Fixture Setup

    // Exercise SUT
    final LocalTime HourAtual = new LocalTime( -12, 12, 25 );

    // Result Verification

    // Fixture Teardown
}
项目:ComputerScienceGraduation    文件:FirstClassJunitIndroduction.java   
@Test( expected = IllegalFieldValueException.class )
public void criaDateFalhaDeAnoBissextoInvalido()
{
    // Fixture Setup

    // Exercise SUT
    final LocalDate dia29Fevereiro = new LocalDate( 2017, 2, 29 );

    // Result Verification

    // Fixture Teardown
}
项目:LAS    文件:MonthOfFixedYearDateTimeField.java   
@Override
public long set(long instant, int value) {
    // Check for illegal values: this is not a lenient field
    if (value < 1 || value > this.numMonthsInYear) {
        throw new IllegalFieldValueException(this.getType(), value, 1, this.numMonthsInYear);
    }
    // What is the current month?
    int monthOfYear = this.get(instant);
    // How many months do we have to add to arrive at the new value
    int monthsToAdd = value - monthOfYear;
    // Now add the required number of months
    return this.add(instant, monthsToAdd);
}
项目:RankTracker    文件:LogFileParserTest.java   
@Test(expectedExceptions = IllegalFieldValueException.class)
public void testDetermineLogStartIllegalField() throws Exception
{
  LogFileParser parser = getParserWithoutLogStart();

  Pattern pattern = LogFileParser.LOGSTART_PATTERN;
  String logFileOpenRow = "Log: Log file open, 09/24/15 219:34:25";

  Matcher matcher = pattern.matcher(logFileOpenRow);
  assertTrue(matcher.matches());

  assertNull(parser.getLogStart());

  parser.determineLogStart(matcher);
}
项目:TinyTravelTracker    文件:FieldUtils.java   
/**
 * 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));
    }
}
项目:TinyTravelTracker    文件:FieldUtils.java   
/**
 * 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));
    }
}
项目:TinyTravelTracker    文件:SkipDateTimeField.java   
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);
}
项目:TinyTravelTracker    文件:BasicSingleEraDateTimeField.java   
/** @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;
}
项目:TinyTravelTracker    文件:ZonedChronology.java   
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) {
        throw new IllegalFieldValueException(iField.getType(), Integer.valueOf(value),
            "Illegal instant due to time zone offset transition: " +
            DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").print(new Instant(localInstant)) +
            " (" + iZone.getID() + ")");
    }
    return result;
}
项目:TinyTravelTracker    文件:JulianChronology.java   
static int adjustYearForSet(int year) {
    if (year <= 0) {
        if (year == 0) {
            throw new IllegalFieldValueException
                (DateTimeFieldType.year(), Integer.valueOf(year), null, null);
        }
        year++;
    }
    return year;
}
项目:TinyTravelTracker    文件:GJLocaleSymbols.java   
public int eraTextToValue(String text) {
    Integer era = iParseEras.get(text);
    if (era != null) {
        return era.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.era(), text);
}
项目:TinyTravelTracker    文件:GJLocaleSymbols.java   
public int monthOfYearTextToValue(String text) {
    Integer month = iParseMonths.get(text);
    if (month != null) {
        return month.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.monthOfYear(), text);
}
项目:TinyTravelTracker    文件:GJLocaleSymbols.java   
public int dayOfWeekTextToValue(String text) {
    Integer day = iParseDaysOfWeek.get(text);
    if (day != null) {
        return day.intValue();
    }
    throw new IllegalFieldValueException(DateTimeFieldType.dayOfWeek(), text);
}
项目:TinyTravelTracker    文件:GJLocaleSymbols.java   
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);
}
项目:TinyTravelTracker    文件:GJChronology.java   
public long set(long instant, int value) {
    if (instant >= iCutover) {
        instant = iGregorianField.set(instant, value);
        if (instant < iCutover) {
            // Only adjust if gap fully crossed.
            if (instant + iGapDuration < iCutover) {
                instant = gregorianToJulian(instant);
            }
            // Verify that new value stuck.
            if (get(instant) != value) {
                throw new IllegalFieldValueException
                    (iGregorianField.getType(), Integer.valueOf(value), null, null);
            }
        }
    } else {
        instant = iJulianField.set(instant, value);
        if (instant >= iCutover) {
            // Only adjust if gap fully crossed.
            if (instant - iGapDuration >= iCutover) {
                instant = julianToGregorian(instant);
            }
            // Verify that new value stuck.
            if (get(instant) != value) {
               throw new IllegalFieldValueException
                    (iJulianField.getType(), Integer.valueOf(value), null, null);
            }
        }
    }
    return instant;
}
项目:springboot-tourreservation    文件:TourFormValidator.java   
@Override
public void validate(Object target, Errors errors) {
    TourForm form = (TourForm) target;
    try {
        new DateTime(form.getDepYear(), form.getDepMonth(), form.getDepDay(), 0, 0).toDate();
    } catch (IllegalFieldValueException e) {
        errors.rejectValue("depYear", "IncorrectDate.inputdate", "Incorrect date was entered.");
    }
}
项目:astor    文件:FieldUtils.java   
/**
 * 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));
    }
}
项目:astor    文件:FieldUtils.java   
/**
 * 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));
    }
}
项目:astor    文件:SkipDateTimeField.java   
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);
}