Merge
authorprr
Tue, 20 Oct 2015 10:33:41 -0700
changeset 33259 bbb84c5a1228
parent 33258 a6a4ca895688 (current diff)
parent 33243 c32d902a31d6 (diff)
child 33260 af1ca24593aa
child 33275 686945c3233e
Merge
--- a/jdk/src/java.base/share/classes/java/time/Instant.java	Tue Oct 20 08:24:37 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/time/Instant.java	Tue Oct 20 10:33:41 2015 -0700
@@ -758,7 +758,7 @@
             throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder");
         }
         long nod = (seconds % LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + nanos;
-        long result = (nod / dur) * dur;
+        long result = Math.floorDiv(nod, dur) * dur ;
         return plusNanos(result - nod);
     }
 
--- a/jdk/test/java/time/tck/java/time/TCKInstant.java	Tue Oct 20 08:24:37 2015 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKInstant.java	Tue Oct 20 10:33:41 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -638,6 +638,12 @@
                 {Instant.ofEpochSecond(86400 + 3600 + 60 + 1, 123_456_789), NINETY_MINS, Instant.ofEpochSecond(86400 + 0, 0)},
                 {Instant.ofEpochSecond(86400 + 7200 + 60 + 1, 123_456_789), NINETY_MINS, Instant.ofEpochSecond(86400 + 5400, 0)},
                 {Instant.ofEpochSecond(86400 + 10800 + 60 + 1, 123_456_789), NINETY_MINS, Instant.ofEpochSecond(86400 + 10800, 0)},
+
+                {Instant.ofEpochSecond(-86400 - 3600 - 60 - 1, 123_456_789), MINUTES, Instant.ofEpochSecond(-86400 - 3600 - 120, 0 )},
+                {Instant.ofEpochSecond(-86400 - 3600 - 60 - 1, 123_456_789), MICROS, Instant.ofEpochSecond(-86400 - 3600 - 60 - 1, 123_456_000)},
+
+                {Instant.ofEpochSecond(86400 + 3600 + 60 + 1, 0), SECONDS, Instant.ofEpochSecond(86400 + 3600 + 60 + 1, 0)},
+                {Instant.ofEpochSecond(-86400 - 3600 - 120, 0), MINUTES, Instant.ofEpochSecond(-86400 - 3600 - 120, 0)},
         };
     }
     @Test(dataProvider="truncatedToValid")