gpt4 book ai didi

java - 将 Bigdecimal 转换为 Integer

转载 作者:行者123 更新时间:2023-12-01 22:18:44 26 4
gpt4 key购买 nike

我在生产线上遇到异常

int cdStatus = ((Integer)vecColumns.elementAt(1)).intValue();


00000050 CommerceSrvr E com.ibm.commerce.command.ECCommandTarget executeCommand CMN0420E:
The following command exception has occurred during processing: "java.lang.ClassCastException: java.math.BigDecimal incompatible with java.lang.Integer".
java.lang.ClassCastException: java.math.BigDecimal incompatible with java.lang.Integer
at com.ibm.commerce.promotion.facade.server.commands.ValidateUniquePromotionCodesTaskCmdImpl.verifyPromotionCodes(ValidateUniquePromotionCodesTaskCmdImpl.java:137)
at com.ibm.commerce.promotion.facade.server.commands.ValidateUniquePromotionCodesTaskCmdImpl.performExecute(ValidateUniquePromotionCodesTaskCmdImpl.java:84)

这里 veColumn 是一个 Vector,elementAt(1) 是数据库中的一个列,在数据库端的类型为smallInt。我不确定这张图中有多大的小数?

最佳答案

您从数组中提取的元素具有 BigDecimal 类型。您无法将 BigDecimal 转换为 Integer。将转换为 Integer 的转换替换为转换为 BigDecimal 的转换,它应该可以工作。

关于java - 将 Bigdecimal 转换为 Integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30423221/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com