List of usage examples for org.joda.time IllegalFieldValueException getFieldName
public String getFieldName()
From source file:org.opentestsystem.delivery.testreg.domain.InvalidFormatBasedDateTimeDeserializer.java
License:Open Source License
private InvalidFormatException convertToInvalidFormatException(IllegalFieldValueException exception) { return new InvalidFormatException(exception.getFieldName(), exception.getIllegalValueAsString(), DateTime.class); }
From source file:se.vgregion.webbisar.types.BirthTime.java
License:Open Source License
public BirthTime(int year, int month, int day, int hour, int minutes) { boolean error = true; int cnt = 0;/*from ww w . ja v a2 s . c om*/ // FIX: This is kind of an hack to make this class kind of "fail safe" while (error && cnt++ < 10) { try { new DateTime(year, month, day, hour, minutes, 0, 0); error = false; } catch (IllegalFieldValueException e) { String s = e.getFieldName(); LOGGER.error("Failed to create DateTime object.", e); if ("dayOfMonth".equals(s)) { day = (day > e.getUpperBound().intValue()) ? e.getUpperBound().intValue() : e.getLowerBound().intValue(); } else if ("monthOfYear".equals(s)) { month = (month > e.getUpperBound().intValue()) ? e.getUpperBound().intValue() : e.getLowerBound().intValue(); } else if ("hourOfDay".equals(s)) { hour = (hour > e.getUpperBound().intValue()) ? e.getUpperBound().intValue() : e.getLowerBound().intValue(); } else if ("minuteOfHour".equals(s)) { minutes = (minutes > e.getUpperBound().intValue()) ? e.getUpperBound().intValue() : e.getLowerBound().intValue(); } } } this.day = day; this.hour = hour; this.minutes = minutes; this.month = month; this.year = year; }