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

后端 未结 6 595
耶瑟儿~
耶瑟儿~ 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:15

    Use this to check date

    String sDate1="31/12/1998 00:00:00";  
    try{
      Date date1=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse(sDate1);  `
    } 
    catch(Exception e)
    {
      //Not a date..
    } 
    

提交回复
热议问题