Helius
2021-03-25 1578973506d65ab44b4835431f027a6e925dabbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.xcong.excoin.utils;
 
 
import java.math.BigDecimal;
 
public class CommonUtils {
 
    /**
     * 根据币种设置小数点
     *
     * @param symbol
     * @param price
     * @return
     */
    public static String amountDotFormat(String symbol, BigDecimal price) {
        String priceFormat = "";
        switch (symbol) {
            case "BTC/USDT":
            case "ETH/USDT":
            case "LTC/USDT":
            case "BCH/USDT":
                priceFormat = price.setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
                break;
            case "EOS/USDT":
            case "XRP/USDT":
            case "ETC/USDT":
                priceFormat = price.setScale(4, BigDecimal.ROUND_DOWN).toPlainString();
                break;
            default:
                priceFormat = price.setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
        }
        return priceFormat;
    }
}