How to use comparison operators like >, =, < on BigDecimal

后端 未结 8 1210
清酒与你
清酒与你 2021-01-30 11:54

I have a domain class with unitPrice set as BigDecimal data type. Now I am trying to create a method to compare price but it seems like I can\'t have comparison operators in Big

8条回答
  •  星月不相逢
    2021-01-30 13:00

    You can use method named compareTo, x.compareTo(y). It will return 0 if x and y are equal, 1 if x is greater than y and -1 if x is smaller than y

提交回复
热议问题