识别任意日期字符串 [英] Recognise an arbitrary date string
问题描述
我需要能够识别日期字符串。如果我无法区分月份和日期(例如12/12/10),我只需要将字符串分类为日期,而不是将其转换为Date对象。所以,这真的是一个分类,而不是解析问题。
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 a date, rather than converting it to a Date object. So, this is really a classification rather than parsing problem.
我将会有一些文字,例如:
I will have pieces of text such as:
bla bla bla bla 12 Jan 09 bla bla bla
01/04/10 bla bla bla
"bla bla bla bla 12 Jan 09 bla bla bla 01/04/10 bla bla bla"
,我需要能够识别每个日期字符串的开始和结束边界。
and I need to be able to recognise the start and end boundary for each date string within.
我想知道是否有人知道任何java图书馆可以做到这一点。到目前为止,我的google-fu还没有提出任何东西。
I was wondering if anyone knew of any java libraries that can do this. My google-fu hasn't come up with anything so far.
更新:我需要能够识别尽可能广泛的代表日期的方式。当然,天真的解决方案可能是为每个可想到的格式编写一个if语句,但是使用经过训练的模型的模式识别方法是理想的我之后。
UPDATE: I need to be able to recognise the widest possible set of ways of representing a dates. Of course the naive solution might be to write an if statement for every conceivable format, but a pattern recognition approach, with a trained model, is ideally what I'm after.
推荐答案
使用 JChronic
您可能想使用 DateParser2 。
这篇关于识别任意日期字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!