Skip to content

Commit

Permalink
Merge branch 'fix-time-conversion-precision' of https://github.com/go…
Browse files Browse the repository at this point in the history
…ogleapis/sdk-platform-java into fix-time-conversion-precision
  • Loading branch information
diegomarquezp committed Aug 15, 2024
2 parents 86d5855 + 5014c4b commit cfa3b06
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class TimeConversionUtilsTest {

// 0.999999999 seconds (1 second - 1 nano) - we need to subtract the nano or the Duration would
// overflow otherwise
final long MAX_DURATION_NANOS = 1 * 1000 * 1000 * 1000 - 1;
final long MAX_DURATION_NANOS =
1 * 1000 /*=1 micro*/ * 1000 /*=1 milli*/ * 1000 /*=1 second*/ - 1;

// Arbitrary durations/instants to confirm conversion works as expected
final org.threeten.bp.Duration ttDuration = org.threeten.bp.Duration.ofMillis(123);
Expand Down Expand Up @@ -96,8 +97,7 @@ void testToJavaTimeInstant_bigInput_doesNotOverflow() {
@Test
void testToThreeteenDuration_bigInput_doesNotOverflow() {
// we use the max long value for the seconds part and an arbitrary int for the nanos part, so we
// can confirm
// that both components are preserved
// can confirm that both components are preserved
java.time.Duration jtDuration =
java.time.Duration.ofSeconds(Long.MAX_VALUE, MAX_DURATION_NANOS);
org.threeten.bp.Duration ttDuration = TimeConversionUtils.toThreetenDuration(jtDuration);
Expand All @@ -108,8 +108,7 @@ void testToThreeteenDuration_bigInput_doesNotOverflow() {
@Test
void testToJavaTimeDuration_bigInput_doesNotOverflow() {
// we use the max long value for the seconds part and an arbitrary int for the nanos part, so we
// can confirm
// that both components are preserved
// can confirm that both components are preserved
org.threeten.bp.Duration ttDuration =
org.threeten.bp.Duration.ofSeconds(Long.MAX_VALUE, MAX_DURATION_NANOS);
java.time.Duration jtDuration = TimeConversionUtils.toJavaTimeDuration(ttDuration);
Expand Down

0 comments on commit cfa3b06

Please sign in to comment.