Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Parsing strings to dates with unknown formats

807589Sep 22 2008 — edited Sep 23 2008
I've perused Java's standard libraries and Joda-time's APIs for date parsing tools, but can't find anything good. I'm reading dates from files where the format is not standardized. So I don't know if it'll be in YYYY-MM-dd or fully spelled out. Also, the dates may be from a LONG time ago, before the 15th century, which is when I understand the Date class stops working properly.

Anybody have any suggestions? I guess I can use Joda-time's DateTimeFormat.forPattern("YYYY-etc...").parse(dateString), catch the formatting exception and try alternative formats successively.... Or do this all manually. But I'm hoping there's a better way and someone has thought of how to handle this. Other's MUST'VE run into this issue before!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 21 2008
Added on Sep 22 2008
11 comments
1,078 views