src/org/ohmage/validator/DateValidators.java
private static Date validate(String date, String format) 
			throws ValidationException {
		
		if(StringUtils.isEmptyOrWhitespaceOnly(date)) {
			return null;
		}
		
		try {
			// SimpleDateFormat is not thread-safe so is has to be created on 
			// every invocation of this method
			SimpleDateFormat formatter = new SimpleDateFormat(format);
			return formatter.parse(date);
			
		} catch (ParseException pe) {
			
			if(LOGGER.isDebugEnabled()) {
				LOGGER.debug("Invalid datetime: " + date + ". It does not match: " + format);
			}
			
			throw new ValidationException(
					ErrorCode.SERVER_INVALID_DATE, 
					"Invalid date: " + date, 
					pe);
		}
	}
/**
	 * @param date The date string to validate
	 * @param format A string representing a valid SimpleDateFormat. 
	 * @return Returns a Date representation of the provided String if the
	 * provided String is parseable and non-null.
	 */
@param date The date string to validate
@param format A string representing a valid SimpleDateFormat.
@return Returns a Date representation of the provided String if the
provided String is parseable and non-null.
@param date The date string to validate @param format A string representing a valid SimpleDateFormat . @return Returns a Date representation of the provided String if the provided String is parseable and non - null .
private static Date validate(String date, String format) 
			throws ValidationException {
		if(StringUtils.isEmptyOrWhitespaceOnly(date)) {
			return null;
		}
		try {
			SimpleDateFormat formatter = new SimpleDateFormat(format);
			return formatter.parse(date);
		} catch (ParseException pe) {
			if(LOGGER.isDebugEnabled()) {
				LOGGER.debug("Invalid datetime: " + date + ". It does not match: " + format);
			}
			throw new ValidationException(
					ErrorCode.SERVER_INVALID_DATE, 
					"Invalid date: " + date, 
					pe);
		}
	}
private static Date validate ( String date , String format ) throws ValidationException { if ( StringUtils . isEmptyOrWhitespaceOnly ( date ) ) { return null ; } try { SimpleDateFormat formatter = new SimpleDateFormat ( format ) ; return formatter . parse ( date ) ; } catch ( ParseException pe ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Invalid datetime: " + date + ". It does not match: " + format ) ; } throw new ValidationException ( ErrorCode . SERVER_INVALID_DATE , "Invalid date: " + date , pe ) ; } }
@param date The date string to validate
 @param format A string representing a valid SimpleDateFormat.
@param date The date string to validate @param format A string representing a valid SimpleDateFormat .
// SimpleDateFormat is not thread-safe so is has to be created on  // every invocation of this method