Extracting dates from text in Java

后端 未结 5 1837
旧时难觅i
旧时难觅i 2021-01-13 17:20

Is it possible to extract dates from a string in Java?

I have 500+ string with different data. In them, there can be:
\"... period from 08.23.2011 - 09.05.2011..

5条回答
  •  执笔经年
    2021-01-13 18:14

    You can extract them with regex first: \d{2}\.\d{2}\.\d{4} and then parse each match with SimpleDateFormat - new SimpleDateFormat("dd.MM.yyyy").parse(dateString)

提交回复
热议问题