code: public static Date valueOf(String s) {
          final int YEAR_LENGTH = 4;
          final int MONTH_LENGTH = 2;
          final int DAY_LENGTH = 2;
          final int MAX_MONTH = 12;
          final int MAX_DAY = 31;
          int firstDash;
          int secondDash;
          Date d = null;
  
          if (s == null) {
              throw new java.lang.IllegalArgumentException();
          }
  
          firstDash = s.indexOf('-');
          secondDash = s.indexOf('-', firstDash + 1);
  
          if ((firstDash > 0) && (secondDash > 0) && (secondDash < s.length() - 1)) {
              String yyyy = s.substring(0, firstDash);
              String mm = s.substring(firstDash + 1, secondDash);
              String dd = s.substring(secondDash + 1);
              if (yyyy.length() == YEAR_LENGTH &&
                      (mm.length() >= 1 && mm.length() <= MONTH_LENGTH) &&
                      (dd.length() >= 1 && dd.length() <= DAY_LENGTH)) {
                  int year = Integer.parseInt(yyyy);
                  int month = Integer.parseInt(mm);
                  int day = Integer.parseInt(dd);
  
                  if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
                      d = new Date(year - 1900, month - 1, day);
                  }
              }
          }
          if (d == null) {
              throw new java.lang.IllegalArgumentException();
          }
  
          return d;
  
      }
docs: Converts a string in JDBC date escape format to
  a <code>Date</code> value.
  
  @param s a <code>String</code> object representing a date in
  in the format "yyyy-[m]m-[d]d". The leading zero for <code>mm</code>
  and <code>dd</code> may also be omitted.
  @return a <code>java.sql.Date</code> object representing the
  given date
  @throws IllegalArgumentException if the date given is not in the
  JDBC date escape format (yyyy-[m]m-[d]d)