Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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


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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading