code: public static Date getDateByPattern(String date)
      {
          if (StringUtils.isNumeric(date))
          {
              return new Date(Long.parseLong(date));
          }
  
          for (String p : patterns)
          {
              try
              {
                  DateFormat formatter = new SimpleDateFormat(p);
                  Date dt = formatter.parse(date);
                  return dt;
              }
              catch (IllegalArgumentException iae)
              {
                  // Do nothing.
                  // move to next pattern.
              }
              catch (ParseException e)
              {
                  // Do nothing.
                  // move to next pattern.
              }
  
          }
          log.error("Required Date format is not supported!" + date);
          throw new PropertyAccessException("Required Date format is not supported!" + date);
      }
docs: Get Date from given below formats.
  
  @param date
  Date pattern
  @return date instance
  @throws PropertyAccessException
  throws only if invalid format is supplied.