private int parseInt(String theValue, String theSubstring, int theLowerBound, int theUpperBound) { int retVal = 0; try { retVal = Integer.parseInt(theSubstring); } catch (NumberFormatException e) { throwBadDateFormat(theValue); } if (retVal < theLowerBound || retVal > theUpperBound) { throwBadDateFormat(theValue); } return retVal; }
private void validateLengthIsAtLeast(String theValue, int theLength) { if (theValue.length() < theLength) { throwBadDateFormat(theValue); } }
private void validateCharAtIndexIs(String theValue, int theIndex, char theChar) { if (theValue.charAt(theIndex) != theChar) { throwBadDateFormat(theValue, "Expected character '" + theChar + "' at index " + theIndex + " but found " + theValue.charAt(theIndex)); } }
private int getOffsetIndex(String theValueString) { int plusIndex = theValueString.indexOf('+', 16); int minusIndex = theValueString.indexOf('-', 16); int zIndex = theValueString.indexOf('Z', 16); int retVal = Math.max(Math.max(plusIndex, minusIndex), zIndex); if (retVal == -1) { return -1; } if ((retVal - 2) != (plusIndex + minusIndex + zIndex)) { throwBadDateFormat(theValueString); } return retVal; }
private BaseDateTimeDt setTimeZone(String theWholeValue, String theValue) { if (isBlank(theValue)) { throwBadDateFormat(theWholeValue); } else if (theValue.charAt(0) == 'Z') { clearTimeZone(); setTimeZoneZulu(true); } else if (theValue.length() != 6) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else if (theValue.charAt(3) != ':' || !(theValue.charAt(0) == '+' || theValue.charAt(0) == '-')) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else { parseInt(theWholeValue, theValue.substring(1, 3), 0, 23); parseInt(theWholeValue, theValue.substring(4, 6), 0, 59); clearTimeZone(); setTimeZone(TimeZone.getTimeZone("GMT" + theValue)); } return this; }
private int parseInt(String theValue, String theSubstring, int theLowerBound, int theUpperBound) { int retVal = 0; try { retVal = Integer.parseInt(theSubstring); } catch (NumberFormatException e) { throwBadDateFormat(theValue); } if (retVal < theLowerBound || retVal > theUpperBound) { throwBadDateFormat(theValue); } return retVal; }
private void validateLengthIsAtLeast(String theValue, int theLength) { if (theValue.length() < theLength) { throwBadDateFormat(theValue); } }
private void validateCharAtIndexIs(String theValue, int theIndex, char theChar) { if (theValue.charAt(theIndex) != theChar) { throwBadDateFormat(theValue, "Expected character '" + theChar + "' at index " + theIndex + " but found " + theValue.charAt(theIndex)); } }
private int getOffsetIndex(String theValueString) { int plusIndex = theValueString.indexOf('+', 16); int minusIndex = theValueString.indexOf('-', 16); int zIndex = theValueString.indexOf('Z', 16); int retVal = Math.max(Math.max(plusIndex, minusIndex), zIndex); if (retVal == -1) { return -1; } if ((retVal - 2) != (plusIndex + minusIndex + zIndex)) { throwBadDateFormat(theValueString); } return retVal; }
private BaseDateTimeDt setTimeZone(String theWholeValue, String theValue) { if (isBlank(theValue)) { throwBadDateFormat(theWholeValue); } else if (theValue.charAt(0) == 'Z') { clearTimeZone(); setTimeZoneZulu(true); } else if (theValue.length() != 6) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else if (theValue.charAt(3) != ':' || !(theValue.charAt(0) == '+' || theValue.charAt(0) == '-')) { throwBadDateFormat(theWholeValue, "Timezone offset must be in the form \"Z\", \"-HH:mm\", or \"+HH:mm\""); } else { parseInt(theWholeValue, theValue.substring(1, 3), 0, 23); parseInt(theWholeValue, theValue.substring(4, 6), 0, 59); clearTimeZone(); setTimeZone(TimeZone.getTimeZone("GMT" + theValue)); } return this; }