src/org/ohmage/util/StringUtils.java
public static Date decodeDateTime(String dateTime) {
		if(isEmptyOrWhitespaceOnly(dateTime)) {
			return null;
		}
		
		try {
			// FIXME: Once we move to only epoch long values, we need to adjust
			// the time zone on these SimpleDateFormat objects to reflect that
			// change, but that assumes we know the sender's timezone. We may
			// want to get rid of this call altogether.
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_AMERICAN_DATE_TIME);
			simpleDateFormat.setLenient(false);
			
			return simpleDateFormat.parse(dateTime);
		}
		catch(ParseException americanException) {
			try {
				SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_ISO_8601_DATE_TIME);
				simpleDateFormat.setLenient(false);
				
				return simpleDateFormat.parse(dateTime);
			}
			catch(ParseException iso8601Exception) {
				
				try {
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_ISO_8601_DATE_TIME_WITH_T);
					simpleDateFormat.setLenient(false);
					
					return simpleDateFormat.parse(dateTime);
				}
				catch(ParseException iso8601WithTException) {
					return null;
				}
			}
		}
	}
/**
	 * Decodes a String representing a date-time and returns a resulting Date
	 * object. The date my follow any of these formats:
	 * <ul>
	 *   <li>{@value #FORMAT_AMERICAN_DATE_TIME}</li>
	 *   <li>{@value #FORMAT_ISO_8601_DATE_TIME}</li>
	 * </ul>
	 * 
	 * @param dateTime The date-time as a String that is to be decoded.
	 * 
	 * @return Returns null if the date-time is null, whitespace only, or 
	 * 		   doesn't follow one of the given format patterns. Otherwise, a 
	 * 		   new Date object that represents the date is returned.
	 */
Decodes a String representing a date-time and returns a resulting Date
object. The date my follow any of these formats:

 #FORMAT_AMERICAN_DATE_TIME
 #FORMAT_ISO_8601_DATE_TIME


@param dateTime The date-time as a String that is to be decoded.

@return Returns null if the date-time is null, whitespace only, or
doesn't follow one of the given format patterns. Otherwise, a
new Date object that represents the date is returned.
Decodes a String representing a date - time and returns a resulting Date object . The date my follow any of these formats : #FORMAT_AMERICAN_DATE_TIME #FORMAT_ISO_8601_DATE_TIME @param dateTime The date - time as a String that is to be decoded . @return Returns null if the date - time is null whitespace only or doesn ' t follow one of the given format patterns . Otherwise a new Date object that represents the date is returned .
public static Date decodeDateTime(String dateTime) {
		if(isEmptyOrWhitespaceOnly(dateTime)) {
			return null;
		}
		try {
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_AMERICAN_DATE_TIME);
			simpleDateFormat.setLenient(false);
			return simpleDateFormat.parse(dateTime);
		}
		catch(ParseException americanException) {
			try {
				SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_ISO_8601_DATE_TIME);
				simpleDateFormat.setLenient(false);
				return simpleDateFormat.parse(dateTime);
			}
			catch(ParseException iso8601Exception) {
				try {
					SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_ISO_8601_DATE_TIME_WITH_T);
					simpleDateFormat.setLenient(false);
					return simpleDateFormat.parse(dateTime);
				}
				catch(ParseException iso8601WithTException) {
					return null;
				}
			}
		}
	}
public static Date decodeDateTime ( String dateTime ) { if ( isEmptyOrWhitespaceOnly ( dateTime ) ) { return null ; } try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( FORMAT_AMERICAN_DATE_TIME ) ; simpleDateFormat . setLenient ( false ) ; return simpleDateFormat . parse ( dateTime ) ; } catch ( ParseException americanException ) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( FORMAT_ISO_8601_DATE_TIME ) ; simpleDateFormat . setLenient ( false ) ; return simpleDateFormat . parse ( dateTime ) ; } catch ( ParseException iso8601Exception ) { try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( FORMAT_ISO_8601_DATE_TIME_WITH_T ) ; simpleDateFormat . setLenient ( false ) ; return simpleDateFormat . parse ( dateTime ) ; } catch ( ParseException iso8601WithTException ) { return null ; } } } }
Decodes a String representing a date-time and returns a resulting Date
 object.
Decodes a String representing a date - time and returns a resulting Date object .
// FIXME: Once we move to only epoch long values, we need to adjust // the time zone on these SimpleDateFormat objects to reflect that // change, but that assumes we know the sender's timezone. We may // want to get rid of this call altogether.