File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
package itn.com.cmm.util;
import java.text.DecimalFormat;
/**
*
* @author : 이호영
* @fileName : PayUtil.java
* @date : 2024.07.16
* @description : pay 다루는 Util
* ===========================================================
* DATE AUTHOR NOTE
* ----------------------------------------------------------- *
* 2023.04.06 이호영 최초 생성
*
*
*
*/
public final class PayUtils {
/**
* @methodName : getTrimToFirstDecimal
* @author : 이호영
* @date : 2023.07.16
* @description : 소수점 첫째자리 빼고 다 버림
* @return ex) 0000.0
*/
public static String getTrimToFirstDecimal(String input) {
try {
// 쉼표 제거
String normalizedInput = input.replace(",", "");
// Double로 변환
double value = Double.parseDouble(normalizedInput);
// 소수점 첫째자리까지만 남기고 나머지는 버림
double trimmedValue = Math.floor(value * 10) / 10.0;
// 숫자가 너무 커지면 지수 표기법으로 나타내서 방지하기 위한 구문
DecimalFormat df = new DecimalFormat("#.0");
// 문자열로 변환하여 반환
return df.format(trimmedValue);
} catch (NumberFormatException e) {
System.err.println("Number format exception: " + e.getMessage());
return "0";
}
}
}