Home > Blockchain >  ArguementType: 'Big Decimal' does not match the type of the format specified '%d'
ArguementType: 'Big Decimal' does not match the type of the format specified '%d'

Time:06-10


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 im getting an error with the string.format method i have used saying "ArguementType: 'Big Decimal' does not match the type of the format specified '%d'" Quantity is defined as a BIG Decimal in DTO class. So how i solve this?

Thanks for helping in advance

CodePudding user response:

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.

  • Related