0

Possible Duplicate:
Parse any date in Java

I'm trying to parse a Date-String into a Date in my JSP Template. The problem is, that I don't know how the Date-String will look like because it's loaded from different RSS-Feeds which will not always have the same date format.

For example:

<fmt:parseDate value="Tue, 05 Jun 2012 11:45:47" var="date" pattern="EEE, dd MMM yyyy HH:mm:ss" parseLocale="US" />

will only work for a date having the format "Tue, 05 Jun 2012 11:45:47"...

I would need something more dynamic as the date could also be "05.06.2012 11:45:47 GMT" or something similar.

I also tried leaving the pattern out but it didn't help.

0

1 Answer 1

1

There are ways to get a positive output. But they can't be reliable for every cent.

For example, if the input date is 2012-06-05 and you have patterns yyyy-MM-dd and yyyy-dd-MM to match with, then resulting month would be 06 i.e. June and 05 i.e. May. These results would raise a confusion in you and you can't decide whether the output is correct in comparison with RSS server date.

There are similar discussions and suggestions available on SO.

  1. Determine if a String is a valid date before parsing
  2. How to convert String to Date without knowing the format?
  3. Parse any date in Java
  4. and may be more ...
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.