String stockStr = " ";
for (StockRecordDTO stockNumber : stockID){
stockStr =
String.format("the stock %s for Date %s with Quantity %d ",
stockNumber.getStock(),
stockNumber.getBusinessDate(),
stockNumber.getQuantity()
);
}
我試圖通過將值提取到字串然后以這種方式列印來列印出值的 ArrayList。我從 DTO 類中獲取值,并且我使用我使用的 string.format 方法出現錯誤說“ArguementType:'Big Decimal' 與指定格式的型別'%d'不匹配”數量定義為DTO 類中的大十進制。那么我該如何解決呢?
感謝您提前幫助
uj5u.com熱心網友回復:
您可以嘗試將其轉換BigDeciaml為double:
stockNumber.getQuantity().doubleValue()
請注意這一點,可能有理由BigDeciamal在您的課程中使用并將其轉換為不同的型別可能會導致精度損失。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/488757.html
