public  boolean isDateValidDDMMYYYY(String date) 
    {
        String DATE_FORMAT = "ddMMyyyy";

            try {
                DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                df.setLenient(false);
                df.parse(date);
                return true;
            } catch (ParseException e) {
                return false;
            }
    }
     
    public  boolean isDateValidYYYYMMDD(String date) 
    {
        String DATE_FORMAT = "yyyyMMdd";

            try {
                DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                df.setLenient(false);
                df.parse(date);
                return true;
            } catch (ParseException e) {
                return false;
            }
    }
    

 

public static boolean isDateValidTime(String time) 
    {
        String DATE_FORMAT = "HHmmss";

            try {
                DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                df.setLenient(false);
                df.parse(time);
                return true;
            } catch (ParseException e) {
                return false;
            }
    }

 

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2021-11-23
  • 2022-02-08
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-02-08
  • 2021-12-11
  • 2021-08-02
相关资源
相似解决方案