code: public Date parseDateOrDatetime(String str) {
          if (str == null)
              return null;
          else if (str.length() <= dateLength)
              return parseDate(str);
          else
              return parseDatetime(str);
      }
docs: /*
  Parse date or date time in string format into Date object.
  
  @param str Date time string to be parsed
  @return Date representation of the string