BigDecimal to Integer/Short/Byte should overflow like BigDecimal to Long does [SPR-14041] #18613
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
andyjojo opened SPR-14041 and commented
fix NumberUtils throws Exception when convert a BigDecimal to Long but sucess when convert to Integer
http://stackoverflow.com/questions/35822941/numberutils-throws-exception-when-convert-a-bigdecimal-to-long-but-sucess-when-c
System.out.println(org.springframework.util.NumberUtils.convertNumberToTargetClass(new BigDecimal("18446744073709551611"), Integer.class));
System.out.println(org.springframework.util.NumberUtils.convertNumberToTargetClass(new BigDecimal("18446744073709551611"), Long.class));
first line returns -5 but second line throws exception java.lang.IllegalArgumentException: Could not convert number [18446744073709551611] of type [java.math.BigDecimal] to target class [java.lang.Long]: overflow
Is that the expect result of method org.springframework.util.NumberUtils.convertNumberToTargetClass?
Affects: 4.2.5
Reference URL: #990
Issue Links:
Referenced from: commits 1ca4340
The text was updated successfully, but these errors were encountered: