##. 소수점 7자리에서 반올림으로 표현하고 소수점 이상은 3자리마다 콤마표시
String price ="12323445.9090900909";
String result = String.format("%,.7f", Double.parseDouble(price));
System.out.println("output: "+result);
String price ="12323445.9090900909";
String result = String.format("%,.7f", Double.parseDouble(price));
System.out.println("output: "+result);
결과
- output: 12,323,445.909
##. java round func 이용한 반올림? (현재 숫자와 가장 근사치인 정수)
String result1 = String.format("%,d", Math.round(Double.parseDouble(price)));
System.out.println("output: "+result1);
결과
- output: 12,323,446
'Dev > java, flex, jsp, js' 카테고리의 다른 글
[펌]비트 연산 (0) | 2009.11.02 |
---|---|
response results에 이상한 값이 앞뒤로 붙는다... 왜?? (1) | 2009.09.29 |
java sleep (시간동안 수행) (2) | 2009.09.08 |
java 형변환 (1) | 2009.09.02 |
Charset and Codepage (310) | 2009.06.26 |