SimpleDateFormat possible error in method parse

前端 未结 3 1650
死守一世寂寞
死守一世寂寞 2021-01-20 07:02

I receive a string that represent a date, I need convert this string to date, and validate that the string is a valid date.

I receive the string 33-12-2013 a the par

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-20 07:42

    Make sure you setLenient(false) on the SimpleDateFormat. Otherwise it will parse lots of invalid dates without exception and you can't trust the output too much.

提交回复
热议问题