java core
[java] 숫자(int)를 문자열(String)로 변경할 때, comma(,)도 같이 표현하고 싶을 때
'김용환'
2016. 3. 7. 19:51
숫자(int)를 String으로 변경할 때, comma(,)를 같이 표현하고 싶을 때, 다양한 방법이 있지만,
java.x.text.NumberFormat을 활용하는 것도 좋은 방법이 될 수 있다.
import java.text.NumberFormat; @Test
public void a111222333() {
String numFormat = NumberFormat.getIntegerInstance().format(111222333);
System.out.println(numFormat);
Assert.equals("111,222,333", numFormat);
} //결과 111,222,333