My Blog

My WordPress Blog

My Blog

My WordPress Blog

10. Java Internationalization

Locale Specific DecimalFormat

By default, DecimalFormat object is using the JVM’s locale. We can change the default locale while creating the DecimalFormat object using NumberFormat class. In the example below, we’ll use same pattern for two different locale and you can spot the difference in the output. Example Open Compiler Output It will print the following result.

Formatting Patterns

Followings is the use of characters in formatting patterns. Sr.No. Class & Description 1 0To display 0 if less digits are present. 2 #To display digit ommitting leading zeroes. 3 .Decimal separator. 4 ,Grouping separator. 5 EMantissa and Exponent separator for exponential formats. 6 ;Format separator. 7 –Negative number prefix. 8 %Shows number as percentage […]

Scroll to top