SimpleDateFormat give inconsistent results

Posted by Julien Gagnet on Stack Overflow See other posts from Stack Overflow or by Julien Gagnet
Published on 2010-03-31T06:53:26Z Indexed on 2010/03/31 7:23 UTC
Read the original article Hit count: 432

Filed under:
|
|

I am trying to parse a date and I am getting different results when I run the code locally/BST compare to a server in Paris/CEST.

I've reproduced the issue in a the following sample. This is trying to parse the start date for the Australian Grand Prix.

    TimeZone tz = TimeZone.getTimeZone("AET");
    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH mm");
    dateFormat.setTimeZone(tz);
    long time = dateFormat.parse("28/03/2010 17 00").getTime();
    System.out.println("Time "+time);

It seems like I am setting the timezone correctly on the date format and the current timezone shouldn't be affecting the code. But locally it prints 1269756000000 and in Paris 1269759600000. Any idea?

© Stack Overflow or respective owner

Related posts about java

Related posts about dateformat