How to use Java to Print Numbers in Hindi

An internationalized program can display information differently throughout the world.

For example, the program will display different messages in India , China, and New York. If the localization process has been fine-tuned,

in Java A Locale object is an identifier for a particular combination of language and region.When creating a Locale object, you usually specify a language code and a country code. A third parameter, the variant, is optional.


So, if you got my point than this is Simple to Print Different messages in Different Languages in java.

An Example Will be Enough to take you Down there...


import java.text.NumberFormat;
import java.util.Locale;

/**
 *
 * @author Aamir Khan
 */
public class Hindi_123 {

    public static void main(String[] args) {
        //set the Locale to Hindi,India
        Locale myloc = new Locale("hi", "in");
        //pass the instace to NumberFormat to Handle the Rest
        NumberFormat nf = NumberFormat.getInstance(myloc);
        for (int i = 0; i <= 100; i++) {

            //print the Numbers
            System.out.println(nf.format(i));
        }

    }

}

No comments :

Post a Comment