cast Long to BigDecimal

后端 未结 6 2043
一向
一向 2021-01-03 17:34

How can I cast Long to BigDecimal?

6条回答
  •  时光说笑
    2021-01-03 18:11

    For completeness you can use:

    // valueOf will return cached instances for values zero through to ten
    BigDecimal d = BigDecimal.valueOf(yourLong);
    

    0 - 10 is as of the java 6 implementation, not sure about previous JDK's

提交回复
热议问题