CORE API / NOTES</>↗Core API12 Aug 2010
You can use the DecimalFormatSymbols class to change the symbols that appear in the formatted numbers. These symbols include the decimal separator which can be changed using the setDecimalSeparator(), the grouping separator which can be change using the setGroupingSeparator() method. You can also alter the minus sign, and the percent sign, among others. package org.kodejava.text; […]
CORE API / NOTES</>↗Core API11 Aug 2010
To change the pattern use by the DecimalFormat when formatting a number we can use the DecimalFormat.applyPattern() method call. In this example we use three different patterns to format the given input number. The pattern determines what the formatted number looks like. package org.kodejava.text; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; public class FormatterPattern { public […]
CORE API / NOTES</>↗Core API08 Aug 2010
The NumberFormat.getPercentInstance() method returns a percentage format for the specified locale. In this example we will format the number as percentage using the Locale.US locale. package org.kodejava.text; import java.text.NumberFormat; import java.util.Locale; public class LocalePercentageFormat { public static void main(String[] args) { // Format percentage for Locale.US locale with this formatter, // a decimal fraction such […]
CORE API / NOTES</>↗Core API04 Aug 2010
Creating a financial application requires you to format number as a currency. It should include the correct thousand separator, decimal separator and the currency symbol. For this purpose you can use the NumberFormat.getCurrencyInstance() method and pass the correct Locale to get the currency format that you want. package org.kodejava.text; import java.text.NumberFormat; import java.util.Locale; public class […]
CORE API / NOTES</>↗Core API31 Jul 2010
Font differences may force you to use different characters on different platforms. You could then define the Locale objects with the variant codes to identify those differences. The variant codes conform to no standard. They are arbitrary and specific to your application. If you create Locale objects with variant codes only your application will know […]
CORE API / NOTES</>↗Core API26 Jul 2010
When you want to internationalize your application, you need to know the language code and country code. These codes will be used as the properties file name (the file name must be ended in language_COUNTRY.properties). Here is an example that show how to get all supported language’s code. package org.kodejava.util; import java.util.Locale; public class LocaleCountryLanguageCode […]