io.gitee.putaoo.easypay.util.AmountUtil Maven / Gradle / Ivy
package io.gitee.putaoo.easypay.util;
import java.math.BigDecimal;
public class AmountUtil {
public static String fenToYuan(Long fen){
BigDecimal decimal = new BigDecimal(fen).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_DOWN);
return decimal.toEngineeringString();
}
public static Long yuanToFen(String yuan){
return BigDecimal.valueOf(Double.parseDouble(yuan)).multiply(BigDecimal.valueOf(100)).longValue();
}
}