Java - How to check if a value is of type Date

后端 未结 6 583
耶瑟儿~
耶瑟儿~ 2021-01-29 09:22

I have a project requirement. There are values in a .txt as -

 02/01/2017 00:00:00

Now I need to have some rules to check if this value in the

6条回答
  •  失恋的感觉
    2021-01-29 10:12

    You can use regular expressions to check the format

    public boolean isDate(String s){
    String pattern= "([0-9]{2})/([0-9]{2})/([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2})";
    return s.matches(pattern);}
    

提交回复
热议问题