7

Using jdk1.7.0_55, I'm getting parseposition.errorIndex as 0 in case of timezone is not standard one.

But using jdk1.6.0_38 I'm getting parseposition.errorIndex as 21 for the same wrong timezone format

Below is the sample:

String date = "13 Jan 2005 21:45:34 ABC";
String format = "dd MMM yyyy HH:mm:ss z";
ParsePosition pp = new ParsePosition(0);
pp.setIndex(0);
SimpleDateFormat sd = new SimpleDateFormat(format,Locale.ENGLISH);
Date d = sd.parse(date,pp);
System.out.println("Error Index "+pp.getErrorIndex());

Result Using jdk 6:

Error Index 21

Result Using jdk 7

Error Index 0

Why there is difference in it?

Please help

3
  • 1
    I can reproduce it. Obviously a regression. You could send this message as bug to OpenJDK. May 6, 2015 at 12:52
  • There shouldn't be but it seems like jdk 6 is giving you date and 7 is giving you pp. May 6, 2015 at 13:17
  • 1
    Both will throw exception if I use parse(date) method. In jdk 6 it gives error index as correct position and in jdk 7 error index as 0. @TaylorCourtney
    – Roshan
    May 7, 2015 at 9:38

1 Answer 1

3

Indeed this is a regression. Still broken in latest Java 8 build. Public OpenJDK bug tracker does not list it, so I have reported it to Oracle for review. It is tracked by Oracle with Review ID: JI-9021556

Unfortunately there is no way for you to fix that.

8
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
    – Marco13
    Jun 2, 2015 at 13:07
  • 3
    it is an answer. The answer is: it is a regression in the JDK. Jun 2, 2015 at 13:09
  • This comment is automatically inserted during review. I'm not about to argue about the subtle difference between "looks like a..." and "is a...", but maybe you could extend the answer with credible information, e.g. a link to your bug report.
    – Marco13
    Jun 2, 2015 at 13:11
  • thanks for nitpicking, i changed the wording of the answer. Also i will update the answer as soon as I receive back the bug ID from oracle. however only parts of their bugtracker are public. Jun 2, 2015 at 13:14
  • 1
    @holodec But this is saying that there is no solution, which is an answer.
    – resueman
    Jun 2, 2015 at 17:29

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.