src/main/java/com/zandero/utils/DateTimeUtils.java
public static long getTimestamp(String value, SimpleDateFormat[] formats) {

		Assert.notNull(formats, "Missing date time formats");
		Assert.isTrue(formats.length > 0, "Missing date time formats");

		if (StringUtils.isNullOrEmptyTrimmed(value)) {
			return 0;
		}

		// OK check if we have 6 digit milliseconds ... if so truncate
		if (value.matches(".*\\.\\d{6}.*")) {
			// remove 3 milliseconds places
			int index = value.indexOf(".");
			value = value.substring(0, index + 4) + value.substring(index + 7);
		}

		// Go over all formats ... and if success return value
		for (SimpleDateFormat format : formats) {

			TimeZone oldDefaultTimeZone = TimeZone.getDefault();

			try {
				// make sure we are in the correct time zone while doing this
				TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

				Date date = format.parse(value);
				return date.getTime();
			}
			catch (ParseException e) {
				// try next one ...
			}
			finally {
				TimeZone.setDefault(oldDefaultTimeZone);
			}
		}

		return 0;
	}
public static long getTimestamp(String value, SimpleDateFormat[] formats) {

		Assert.notNull(formats, "Missing date time formats");
		Assert.isTrue(formats.length > 0, "Missing date time formats");

		if (StringUtils.isNullOrEmptyTrimmed(value)) {
			return 0;
		}

		// OK check if we have 6 digit milliseconds ... if so truncate
		if (value.matches(".*\\.\\d{6}.*")) {
			// remove 3 milliseconds places
			int index = value.indexOf(".");
			value = value.substring(0, index + 4) + value.substring(index + 7);
		}

		// Go over all formats ... and if success return value
		for (SimpleDateFormat format : formats) {

			TimeZone oldDefaultTimeZone = TimeZone.getDefault();

			try {
				// make sure we are in the correct time zone while doing this
				TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

				Date date = format.parse(value);
				return date.getTime();
			}
			catch (ParseException e) {
				// try next one ...
			}
			finally {
				TimeZone.setDefault(oldDefaultTimeZone);
			}
		}

		return 0;
	}
Convert any given timestamp string to long
Note that in case conversion fails to produce a result a 0 timestamp is returned!

@param value   to be converted
@param formats list of formats to try out
@return time stamp or 0 if conversion failed