How to check if a string is date?

前端 未结 5 2100
渐次进展
渐次进展 2020-12-17 19:39

I am having string like

\"11-04-2015 22:01:13:053\" or \"32476347656435\"

How can I check if string is Date?
Checking String if it is n

5条回答
  •  悲&欢浪女
    2020-12-17 20:04

    You can use Apache Commons Validator. It provides validation framework for validating date, time, numbers, currency, IP address, email, and URL.

    Maven dependency:

    
        commons-validator
        commons-validator
        1.6
    
    

    Example:

    assertTrue(GenericValidator.isDate("2019-02-28", "yyyy-MM-dd", true))
    

提交回复
热议问题