1

Running this program:

import java.text.*;
import java.util.*;
public class xx {
    public static void main(String[] args) throws Exception {
        final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
        format.setLenient(false);
        format.parse("Tue, 16 Jan 2010 04:41:09 -0000");
    }
}

Gives this result (java version "1.7.0_17"):

Exception in thread "main" java.text.ParseException: Unparseable date: "Tue, 16 Jan 2010 04:41:09 -0000"
at java.text.DateFormat.parse(DateFormat.java:357)
at xx.main(xx.java:7)

It appears that when set to non-lenient mode, the Tue, prefix is what fails to parse.

Question is, why does EEE, fail to match the Tue, prefix of the date string?

Archie
  • 4,959
  • 1
  • 30
  • 36

1 Answers1

7

That's because January 16th wasn't a Tuesday, it was a Saturday.

public static void main(String args[]) throws ParseException {
    final SimpleDateFormat format = new SimpleDateFormat(
            "EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
    format.setLenient(false);
    format.parse("Sat, 16 Jan 2010 04:41:09 -0000");
}

works just fine.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724