code: public static Date parse(String source, final String pattern) {
  
  		if (StringUtils.isBlank(pattern)) {
  
  			return parseISO8601DateString(source);
  
  		} else {
  
  			try {
  				// SimpleDateFormat is not fully ISO8601 compatible, so we replace 'Z' by +0000
  				if (StringUtils.contains(source, "Z")) {
  
  					source = StringUtils.replace(source, "Z", "+0000");
  				}
  
  				return new SimpleDateFormat(pattern).parse(source);
  
  			} catch (ParseException ignore) { }
  
  			// try to parse as ISO8601 date (supports multiple formats)
  			return parseISO8601DateString(source);
  
  		}
  
  	}
docs: Static method to catch parse exception
  
  @param source
  @param pattern optional SimpleDateFormat pattern
  @return