Helius
2021-04-14 f3948fa31158c7b7dea3b038e01c43ce54c55a1c
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
35
36
37
38
39
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 = "";
 
        if (price == null) {
            return "";
        }
 
        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;
    }
}