src/java.base/share/classes/java/time/OffsetTime.java

Print this page
rev 12809 : 8023217: Additional floorDiv/floorMod/multiplyExact methods for java.lang.Math
Summary: Add new methods with long, int signatures.
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 2012, 2013, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 256,266 **** Objects.requireNonNull(instant, "instant"); Objects.requireNonNull(zone, "zone"); ZoneRules rules = zone.getRules(); ZoneOffset offset = rules.getOffset(instant); long localSecond = instant.getEpochSecond() + offset.getTotalSeconds(); // overflow caught later ! int secsOfDay = (int) Math.floorMod(localSecond, SECONDS_PER_DAY); LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano()); return new OffsetTime(time, offset); } //----------------------------------------------------------------------- --- 256,266 ---- Objects.requireNonNull(instant, "instant"); Objects.requireNonNull(zone, "zone"); ZoneRules rules = zone.getRules(); ZoneOffset offset = rules.getOffset(instant); long localSecond = instant.getEpochSecond() + offset.getTotalSeconds(); // overflow caught later ! int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY); LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano()); return new OffsetTime(time, offset); } //-----------------------------------------------------------------------