Skip to content

Commit b83c1df

Browse files
committed
Return a BigDecimal instead of a double when the timestamp have milliseconds part
1 parent 644e55d commit b83c1df

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

smithy-model/src/main/java/software/amazon/smithy/model/loader/TaggedStringLiteral.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package software.amazon.smithy.model.loader;
66

7+
import java.math.BigDecimal;
78
import java.nio.charset.StandardCharsets;
89
import java.time.Instant;
910
import java.time.format.DateTimeParseException;
@@ -196,8 +197,8 @@ private static Result scanTimestampContents(CharSequence lexeme) {
196197
if (millis == 0) {
197198
return Result.ofNumber(epochSecond);
198199
}
199-
double value = epochSecond + millis / 1000.0;
200-
return Result.ofNumber(value);
200+
BigDecimal epochSecondWithMillis = BigDecimal.valueOf(epochSecond).add(BigDecimal.valueOf(millis, 3));
201+
return Result.ofNumber(epochSecondWithMillis);
201202
} catch (DateTimeParseException e) {
202203
throw new RuntimeException("Invalid RFC 3339 timestamp: " + lexeme);
203204
}

0 commit comments

Comments
 (0)