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!

Error in the conversion of a date in ms for october before 1996

1031297Aug 7 2013 — edited Aug 8 2013

Hi,

I have the following problems (using of the jdk 1.5.0_15)

One hour is systematicallay added when i ask to convert a date in millisecond for a date with first days of the month of october before 1996.

Unit test

try {

  SimpleDateFormat form = new SimpleDateFormat(

  "yyyy-MM-dd HH:mm:ss.S");

  Date date = form.parse("1995-09-06 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("810338400000");

  date = form.parse("1995-10-06 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("812930400000");

  date = form.parse("1995-10-30 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("815007600000");

  date = form.parse("1995-11-06 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("815612400000");

  date = form.parse("1996-10-06 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("844552800000");

  date = form.parse("1996-11-06 00:00:00.0");

  System.out.println(date.getTime());

  System.out.println("847234800000");

  } catch (Exception e) {

       e.printStackTrace();

  }

A decalage appears for 1995-10-06 00:00:00.0, the result should be 812930400000 but 812934000000 (1 hour more) is retrieved.

Anyone has an idea what's happening?

sincerely

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2013
Added on Aug 7 2013
11 comments
814 views