code: public static Date parseDate(String dateStr, String pattern) {
          try {
              SimpleDateFormat format = null;
              if (StringUtils.isBlank(dateStr))
                  return null;
              if (StringUtils.isNotBlank(pattern)) {
                  format = new SimpleDateFormat(pattern);
                  return format.parse(dateStr);
              }
              return parseDate(dateStr);
          } catch (Exception e) {
              throw new RuntimeException("无法解析日期字符[" + dateStr + "]");
          }
      }
docs: 解析日期字符串转化成日期格式<br>
  generate by: vakin jiang at 2012-3-1
  
  @param dateStr
  @param pattern
  @return