DateFormatter that is not picky?

前端 未结 2 1168
长情又很酷
长情又很酷 2021-01-20 05:42

Does anyone know of a DateFormatter in Java that isn\'t so picky? By that I mean I could provide it multiple formats the date could be written in and if I provide it a forma

2条回答
  •  無奈伤痛
    2021-01-20 06:31

    You can have a look at the method

    DateUtils.parse(String, String[])

    from apache commons / lang. It allows you to specify multiple patterns, all of which will be checked until one can successfully parse the date. (This is very similar to your own suggested usage).

提交回复
热议问题