How can I change DecimalFormat behavior based on input length?

后端 未结 2 1569
遇见更好的自我
遇见更好的自我 2021-02-15 10:55

I am using the following DecimalFormat pattern:

// Use ThreadLocal to ensure thread safety.
private static final ThreadLocal  nu         


        
相关标签:
2条回答
  • 2021-02-15 11:32
    DecimalFormat("#,##0.00#")
    
    0 讨论(0)
  • 2021-02-15 11:43

    Have you tried to change the RoundingMode of your DecimalFormat instance?

    Calling setRoundingMode(RoundingMode.FLOOR) should do the trick

    See also setRoundingMode(java.math.RoundingMode)

    0 讨论(0)
提交回复
热议问题