Created
December 30, 2021 16:28
-
-
Save adojos/b8c17d2e8b2af4b43df92c35de7031e8 to your computer and use it in GitHub Desktop.
Java: Format Decimal with String Literals #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 DecimalFormatAndStringLiteral { | |
public static void main(String[] args) { | |
double dbNum = 170180.24551D; | |
String strPattern = "My formatted number is #,###.###"; | |
DecimalFormat deciFormat = new DecimalFormat(strPattern); | |
String strFormattedNum = deciFormat.format(dbNum); | |
System.out.println(strFormattedNum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment