Skip to content

Instantly share code, notes, and snippets.

@adojos
Last active March 9, 2023 11:10
Show Gist options
  • Save adojos/219bd6a59d7bd881631c58a62a5ed178 to your computer and use it in GitHub Desktop.
Save adojos/219bd6a59d7bd881631c58a62a5ed178 to your computer and use it in GitHub Desktop.
Java: Format Decimal with Group Separator for Int #java
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