mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
update huifu
This commit is contained in:
@@ -3,7 +3,11 @@ package com.jsowell.common.util;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* 汇付支付的工具类
|
||||
*/
|
||||
public class AdapayUtil {
|
||||
|
||||
public static void main(String[] args) {
|
||||
String amount = "1110.5309";
|
||||
String s = formatAmount(amount);
|
||||
@@ -14,15 +18,24 @@ public class AdapayUtil {
|
||||
System.out.println(s2);
|
||||
}
|
||||
|
||||
// 格式化数字 保留两位小数,不足补0
|
||||
/**
|
||||
* 格式化数字 保留两位小数,不足补0
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public static String formatAmount(String amount) {
|
||||
//保留2位小数
|
||||
double score = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
double d = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
//不足两位则补0
|
||||
DecimalFormat decimalFormat = new DecimalFormat("0.00#");
|
||||
return decimalFormat.format(score);
|
||||
return decimalFormat.format(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化数字 保留两位小数,不足补0
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public static String formatAmount(BigDecimal amount) {
|
||||
return formatAmount(amount.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user