code: public static Date stringToDate(String dateText, String format,
                                      boolean lenient) {
  
          if (dateText == null) {
  
              return null;
          }
  
          DateFormat df = null;
  
          try {
  
              if (format == null) {
                  df = new SimpleDateFormat();
              } else {
                  df = new SimpleDateFormat(format);
              }
  
              // setLenient avoids allowing dates like 9/32/2001
              // which would otherwise parse to 10/2/2001
              df.setLenient(false);
  
              return df.parse(dateText);
          } catch (ParseException e) {
  
              return null;
          }
      }
docs: 字符串转换为日期java.util.Date
  
  @param dateText
  字符串
  @param format
  日期格式
  @param lenient
  日期越界标志
  @return