Generic way to parse dates in Java

后端 未结 7 851
醉酒成梦
醉酒成梦 2021-01-19 00:03

What is the best way to parse dates in Java ? Is there any built in way to parse strings such as \"18 Jul 2011\" , \"Jul 18, 2011\", \"18-07-2011\", \"2011-07-18\" without k

相关标签:
7条回答
  • 2021-01-19 00:55

    You can't really do that. Consider "10-12-2011". Do you mean 10 of december or 12 of october? You need to make your own list of patterns to try out. This list will vary depending on locale and what is the "expected" way someone in that country/locale will interpret the date.

    0 讨论(0)
提交回复
热议问题