본문 바로가기
Java

숫자 천단위마다 (,) 찍는 방법

by 루에 2015. 5. 28.
반응형

String.format("%,d", value);

value에 숫자형 데이터를 넣는다.


String.format에서 지원하는 종류


Converter Flag Explanation

d A decimal integer.

f A float.

n A new line character appropriate to the platform running the application. You should always use %n, rather than \n.

tB A date & time conversion—locale-specific full name of month.

td, te A date & time conversion—2-digit day of month. td has leading zeroes as needed, te does not.

ty, tY A date & time conversion—ty = 2-digit year, tY = 4-digit year.

tl A date & time conversion—hour in 12-hour clock.

tM A date & time conversion—minutes in 2 digits, with leading zeroes as necessary.

tp A date & time conversion—locale-specific am/pm (lower case).

tm A date & time conversion—months in 2 digits, with leading zeroes as necessary.

tD A date & time conversion—date as %tm%td%ty

  08 Eight characters in width, with leading zeroes as necessary.

  + Includes sign, whether positive or negative.

  , Includes locale-specific grouping characters.

  - Left-justified..

  .3 Three places after decimal point.

  10.3 Ten characters in width, right justified, with three places after decimal point.





반응형

댓글