This discussion is archived
11 Replies Latest reply: Aug 8, 2013 2:02 PM by rp0428 Branched to a new discussion. RSS

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

9276a535-dffa-4af7-8a91-666a72d8e9a2 Newbie
Currently Being Moderated

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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points