-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8..0-60"
Java (TM) SE Runtime Environment (build 1.8.0_60-b27)
Java Hotspot (TM) Client VM (build 25.60-b23,, mixed mode,sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
A DESCRIPTION OF THE PROBLEM :
I was using dqte.getTime() to calculate the time between 2 times (by subtracting the milliseconds for the 2 moments in time)
For some values I received a negative value, although I subtracted the value for the oldest time from the value for the newest time.
Example: the difference between 8/04/2015 11:58:57 and 8/04/2015 12:12:50 gave -42367000 ms. (Expected value is 833000 ms)
Further experiments revealed:
ms since 1-1-1970 for 8/04/2015 11:59:59 returns 1428487199000
ms since 1-1-1970 for 8/04/2015 12:00:00 returns 1428444000000
(both dates are april 8 2015).
Although the 2nd time is 1 second more in the future than the first, the value that getTime returns is much smaller. It was expected to be 1000 higher.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Code to reproduce the fault:
DateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
try
{
Date date = format.parse("8/04/2015 11:59:59");
System.out.println("8/04/2015 11:59:59 --> " + Long.toString( date.getTime()));
Date date = format.parse("8/04/2015 12:00:00");
System.out.println("8/04/2015 12:00:00 --> " + Long.toString( date.getTime()));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result was that getTime returned 1428487200000 (1428487199000 + 1000) for 8/04/2015 12:00:00
ACTUAL -
getTime() returned 1428444000000
This seems to happen for all times of the format 8/04/2015 12:xx:xx
Starting at 8/04/2015 13:00:00 is back as expected again.
Also:
When creating a Date object for the Long values 1428487970000 and 1428444770000, and then printing the time from these objects inhuman readable form, both result in 8/04/2015 12:12:50
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error message. Only faulty result from calculations
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See steps to reproduce
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None that I know of
java version "1.8..0-60"
Java (TM) SE Runtime Environment (build 1.8.0_60-b27)
Java Hotspot (TM) Client VM (build 25.60-b23,, mixed mode,sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.3.9600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
A DESCRIPTION OF THE PROBLEM :
I was using dqte.getTime() to calculate the time between 2 times (by subtracting the milliseconds for the 2 moments in time)
For some values I received a negative value, although I subtracted the value for the oldest time from the value for the newest time.
Example: the difference between 8/04/2015 11:58:57 and 8/04/2015 12:12:50 gave -42367000 ms. (Expected value is 833000 ms)
Further experiments revealed:
ms since 1-1-1970 for 8/04/2015 11:59:59 returns 1428487199000
ms since 1-1-1970 for 8/04/2015 12:00:00 returns 1428444000000
(both dates are april 8 2015).
Although the 2nd time is 1 second more in the future than the first, the value that getTime returns is much smaller. It was expected to be 1000 higher.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Code to reproduce the fault:
DateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
try
{
Date date = format.parse("8/04/2015 11:59:59");
System.out.println("8/04/2015 11:59:59 --> " + Long.toString( date.getTime()));
Date date = format.parse("8/04/2015 12:00:00");
System.out.println("8/04/2015 12:00:00 --> " + Long.toString( date.getTime()));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected result was that getTime returned 1428487200000 (1428487199000 + 1000) for 8/04/2015 12:00:00
ACTUAL -
getTime() returned 1428444000000
This seems to happen for all times of the format 8/04/2015 12:xx:xx
Starting at 8/04/2015 13:00:00 is back as expected again.
Also:
When creating a Date object for the Long values 1428487970000 and 1428444770000, and then printing the time from these objects inhuman readable form, both result in 8/04/2015 12:12:50
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error message. Only faulty result from calculations
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See steps to reproduce
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None that I know of