Recognise an arbitrary date string

后端 未结 14 812
抹茶落季
抹茶落季 2020-12-01 16:18

I need to be able to recognise date strings. It doesn\'t matter if I can not distinguish between month and date (e.g. 12/12/10), I just need to classify the string as being

相关标签:
14条回答
  • 2020-12-01 16:46

    I don't know of any library that can do this but writing your own wouldn't be incredibly hard. Assuming your dates are all formatted with the slashes like 12/12/12 then you could verify you have three '\'s. You could get even more technical and have it check the values in between the slashes. For instance, if you have:

    30/12/10

    Then you know that 30 is the days and 12 is the month. However if you get 30/30/10 you know that even though ti has the correct format, it cannot be a date because there are no '30' months.

    0 讨论(0)
  • 2020-12-01 16:48

    Very good date parser in java is Natty, you can try it here

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