src/main/java/com/teamunify/i18n/I.java
public static Date stringToTimestamp(String source, Date defaultDate) {
    String date;
    String time;
    source = source.trim();

    if(source.length() < 2 || !source.contains(" "))
      return defaultDate;

    Matcher ampmMatcher = jammedAmPm.matcher(source);

    if (ampmMatcher.matches()) {
      String ampm = source.substring(source.length() - 2);
      source = source.substring(0, source.length() - 2) + " " + ampm;
    }

    Matcher m = timestampPattern.matcher(source);
    if (m.matches()) {
      date = m.group(1);
      time = m.group(2);
    } else { // do our best...
      int firstSpace = source.indexOf(' ');
      date = source.substring(0, firstSpace);
      time = source.substring(firstSpace + 1);
    }
    Date d = stringToDate(date);
    if (isNullDate(d))
      d = defaultDate;

    return stringToTime(d, time);
  }
/**
   * Convert an incoming string that is composed of a date and time into a Date object. This function is designed to be
   * very tolerant of user input. It will always accept ISO format: yyyy-MM-dd hh:mm:ss, but will also accept many
   * localized, non-ambiguous version of a timestamp (mm/dd/yy hh:mm, MMM dd, yyyy hh:mm, etc.)
   *
   * @param source      The string to interpret.
   * @param defaultDate date to return if all parsing fails (overrides the global default date for this call).
   * @return The Date the represented in the string, to as much accuracy as can be derived from the string.
   */
Convert an incoming string that is composed of a date and time into a Date object. This function is designed to be
very tolerant of user input. It will always accept ISO format: yyyy-MM-dd hh:mm:ss, but will also accept many
localized, non-ambiguous version of a timestamp (mm/dd/yy hh:mm, MMM dd, yyyy hh:mm, etc.)

@param source      The string to interpret.
@param defaultDate date to return if all parsing fails (overrides the global default date for this call).
@return The Date the represented in the string, to as much accuracy as can be derived from the string.
Convert an incoming string that is composed of a date and time into a Date object . This function is designed to be very tolerant of user input . It will always accept ISO format : yyyy - MM - dd hh : mm : ss but will also accept many localized non - ambiguous version of a timestamp ( mm / dd / yy hh : mm MMM dd yyyy hh : mm etc . ) @param source The string to interpret . @param defaultDate date to return if all parsing fails ( overrides the global default date for this call ) . @return The Date the represented in the string to as much accuracy as can be derived from the string .
public static Date stringToTimestamp(String source, Date defaultDate) {
    String date;
    String time;
    source = source.trim();
    if(source.length() < 2 || !source.contains(" "))
      return defaultDate;
    Matcher ampmMatcher = jammedAmPm.matcher(source);
    if (ampmMatcher.matches()) {
      String ampm = source.substring(source.length() - 2);
      source = source.substring(0, source.length() - 2) + " " + ampm;
    }
    Matcher m = timestampPattern.matcher(source);
    if (m.matches()) {
      date = m.group(1);
      time = m.group(2);
    } else { 
      int firstSpace = source.indexOf(' ');
      date = source.substring(0, firstSpace);
      time = source.substring(firstSpace + 1);
    }
    Date d = stringToDate(date);
    if (isNullDate(d))
      d = defaultDate;
    return stringToTime(d, time);
  }
public static Date stringToTimestamp ( String source , Date defaultDate ) { String date ; String time ; source = source . trim ( ) ; if ( source . length ( ) < 2 || ! source . contains ( " " ) ) return defaultDate ; Matcher ampmMatcher = jammedAmPm . matcher ( source ) ; if ( ampmMatcher . matches ( ) ) { String ampm = source . substring ( source . length ( ) - 2 ) ; source = source . substring ( 0 , source . length ( ) - 2 ) + " " + ampm ; } Matcher m = timestampPattern . matcher ( source ) ; if ( m . matches ( ) ) { date = m . group ( 1 ) ; time = m . group ( 2 ) ; } else { int firstSpace = source . indexOf ( ' ' ) ; date = source . substring ( 0 , firstSpace ) ; time = source . substring ( firstSpace + 1 ) ; } Date d = stringToDate ( date ) ; if ( isNullDate ( d ) ) d = defaultDate ; return stringToTime ( d , time ) ; }
Convert an incoming string that is composed of a date and time into a Date object.
Convert an incoming string that is composed of a date and time into a Date object .
// do our best...