Author: saqibkhan
-
DecimalFormat Class
The java.text.DecimalFormat class is used for formatting numbers as per customized format and as per locale. Example – Format Numbers In this example, we’re formatting numbers based on a given pattern. Open Compiler Output It will print the following result.
-
Parse Numbers
Example In this example, we’re showcasing parsing of number present in different locale. Open Compiler Output It will print the following result.
-
Set Rounding Mode
Example In this example, we’re showcasing Rounding Mode. Open Compiler Output It will print the following result.
-
Example
In this example, we’re setting min and max digits for both integer as well as fractional part of a number. Open Compiler Output It will print the following result.
-
Format Percentages
Example In this example, we’re formatting numbers in percentage format. Open Compiler Output It will print the following result.
-
Format Currencies
In this example, we’re formatting currencies based on US locale and Danish Locale. Example Open Compiler Output It will print the following result.
-
NumberFormat Class
The java.text.NumberFormat class is used for formatting numbers and currencies as per a specific Locale. Number formats varies from country to country. For example, In Denmark fractions of a number are separated from the integer part using a comma whereas in England they use a dot as separator. Example – Format Numbers In this example,…
-
ResourceBundle Class
ResourceBundle class is used to store text and objects which are locale sensitive. Generally we use property files to store locale specific text and then represent them using ResourceBundle object. Following are the steps to use locale specific properties file in a java based application. Step 1: Create Properties Files Suppose we need properties file…
-
Locale Language
Example In this example, we’ll get display language per locale passed as an argument. Open Compiler Output It will print the following result.
-
Locale Details
Example In this example, we’ll get default locale and print its details. Then create a locale for “fr” and print its details. Open Compiler Output It will print the following result.