Last active
March 9, 2023 11:10
-
-
Save adojos/219bd6a59d7bd881631c58a62a5ed178 to your computer and use it in GitHub Desktop.
Java: Format Decimal with Group Separator for Int #java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DecimalFormat; | |
public class DecimalFormatGrouping { | |
public static void main(String[] args) { | |
double dbNum = 170180.24551D; | |
DecimalFormat dFormat = new DecimalFormat(); | |
dFormat.setGroupingSize(4); | |
String strFormattedNum = dFormat.format(dbNum); | |
System.out.println(dbNum + " GroupSize(4) = " + strFormattedNum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment