grongytype:'大十进制'不匹配指定格式的类型'%d'

发布于 2025-02-06 18:44:20 字数 522 浏览 3 评论 0原文

String stockStr = " ";

for (StockRecordDTO stockNumber : stockID)
{
    stockStr+= 

    String.format("the stock %s for Date %s with Quantity %d ", 
            stockNumber.getStock(),
            stockNumber.getBusinessDate(), 
            stockNumber.getQuantity()
        );
}

我试图通过将值提取到字符串然后以这种方式打印出值来打印出值的数组列表。我正在从DTO类中获取值,并且我使用string.format我使用的方法会遇到错误

参数类型:“大十进制”不匹配指定格式的类型'%d'

,定义为DTO类中的大十进制。

那么我该如何解决呢?

感谢您提前帮助

String stockStr = " ";

for (StockRecordDTO stockNumber : stockID)
{
    stockStr+= 

    String.format("the stock %s for Date %s with Quantity %d ", 
            stockNumber.getStock(),
            stockNumber.getBusinessDate(), 
            stockNumber.getQuantity()
        );
}

I am trying to print out an ArrayList of values by extracting it to a string and then printing it this way. I am getting the Values from a DTO class, and I'm getting an error with the string.format method I have used saying

ArgumentType: 'Big Decimal' does not match the type of the format specified '%d'

Quantity is defined as a BIG Decimal in DTO class.

So how do I solve this?

Thanks for helping in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2025-02-13 18:44:20

您可以尝试将bigdeciaml转换为double

stockNumber.getQuantity().doubleValue()

请小心,可能会有一个理由在类中使用bigdeciamal它可能会导致精确度的丧失。

You could try to convert the BigDeciaml to a double:

stockNumber.getQuantity().doubleValue()

Be careful with that, there might be a reason to use BigDeciamal in you class and converting it to a different type might lead to loss of precision.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文