Describe the bug
When converting a negative Duration with a non-zero nanosecond offset, DynamoDB enhanced client's DurationAttributeConverter.transformFrom will return a value that does not match the input. Passing that returned value back into DurationAttributeConverter.transformTo will not return a Duration equal to the original value.
Regression Issue
Expected Behavior
I expect that I will receive an equivalent value after converting a negative Duration with a non-zero nanosecond offset to and from an AttributeValue with DurationAttributeConverter.
For example, if I create a DurationAttributeConverter named converter and call converter.transformFrom(Duration.ofMillis(-1)), I'd expect to receive AttributeValue.fromN("-0.001000000"). Subsequently calling converter.transformTo on that result should return Duration.ofMillis(-1).
Current Behavior
Rather than receiving an equivalent value, I received a different value Duration.parse("PT-1.999S") from the transformTo call and a value of AttributeValue.fromN("-1.999000000") from the transformFrom call.
Reproduction Steps
DurationAttributeConverter converter = DurationAttributeConverter.create();
Duration original = Duration.ofMillis(-1);
// This assertion will fail
assert original.equals(converter.transformTo(converter.transformFrom(original)));
Possible Solution
The most likely reason for this bug is the internal representation used by Java for negative durations. From the java.time.Duration.getSeconds Javadoc:
A negative duration is expressed by the negative sign of the seconds part. A duration of -1 nanosecond is stored as -1 seconds plus 999,999,999 nanoseconds.
Additional Information/Context
No response
AWS Java SDK version used
2.41.32
JDK version used
openjdk 25.0.3 2026-04-21 LTS OpenJDK Runtime Environment Corretto-25.0.3.9.1 (build 25.0.3+9-LTS) OpenJDK 64-Bit Server VM Corretto-25.0.3.9.1 (build 25.0.3+9-LTS, mixed mode, sharing)
Operating System and version
Rocky Linux release 8.10 (Green Obsidian), but will occur on any OS
Describe the bug
When converting a negative
Durationwith a non-zero nanosecond offset, DynamoDB enhanced client'sDurationAttributeConverter.transformFromwill return a value that does not match the input. Passing that returned value back intoDurationAttributeConverter.transformTowill not return aDurationequal to the original value.Regression Issue
Expected Behavior
I expect that I will receive an equivalent value after converting a negative
Durationwith a non-zero nanosecond offset to and from anAttributeValuewithDurationAttributeConverter.For example, if I create a
DurationAttributeConverternamedconverterand callconverter.transformFrom(Duration.ofMillis(-1)), I'd expect to receiveAttributeValue.fromN("-0.001000000"). Subsequently callingconverter.transformToon that result should returnDuration.ofMillis(-1).Current Behavior
Rather than receiving an equivalent value, I received a different value
Duration.parse("PT-1.999S")from thetransformTocall and a value ofAttributeValue.fromN("-1.999000000")from thetransformFromcall.Reproduction Steps
Possible Solution
The most likely reason for this bug is the internal representation used by Java for negative durations. From the
java.time.Duration.getSecondsJavadoc:Additional Information/Context
No response
AWS Java SDK version used
2.41.32
JDK version used
openjdk 25.0.3 2026-04-21 LTS OpenJDK Runtime Environment Corretto-25.0.3.9.1 (build 25.0.3+9-LTS) OpenJDK 64-Bit Server VM Corretto-25.0.3.9.1 (build 25.0.3+9-LTS, mixed mode, sharing)
Operating System and version
Rocky Linux release 8.10 (Green Obsidian), but will occur on any OS