Converting BigDecimal to Integer

后端 未结 8 1012
既然无缘
既然无缘 2020-12-04 14:43

I have Hibernate method which returns me a BigDecimal. I have another API method to which I need to pass that number but it accepts Integer as parameter. I cannot change ret

8条回答
  •  Happy的楠姐
    2020-12-04 15:33

    Can you guarantee that the BigDecimal will never contain a value larger than Integer.MAX_VALUE?

    If yes, then here's your code calling intValue:

    Integer.valueOf(bdValue.intValue())
    

提交回复
热议问题