Localizing Data:
gettimeinstance--represents time
1 PackageCHAP2;2 3 ImportJava.text.DateFormat;4 Importjava.util.Date;5 ImportJava.util.Locale;6 7 Public classDatademo {8 Public Static voidMain (string[] args) {9DateFormat df=dateformat.gettimeinstance (Dateformat.long,NewLocale ("de", "de"));TenString Date =df.format (NewDate ()); One System.out.print (date); A - - } the}
getdateinstance--represents the date:
1 PackageCHAP2;2 3 ImportJava.text.DateFormat;4 Importjava.util.Date;5 ImportJava.util.Locale;6 7 Public classDatademo {8 Public Static voidMain (string[] args) {9DateFormat df=dateformat.getdateinstance (Dateformat.long,NewLocale ("de", "de"));TenString Date =df.format (NewDate ()); One System.out.print (date); A - - } the}
Localizing Currency:
1 PackageCHAP2;2 3 ImportJava.text.NumberFormat;4 ImportJava.util.Locale;5 6 Public classCurrencydemo {7 Static intnumber=1000000;8 Public Static voidMain (String args[]) {9NumberFormat NFT =numberformat.getcurrencyinstance (NewLocale ("de", "de"));TenString formatted =Nft.format (number); One System.out.println (formatted); A - } - the}
Localizing Text:
1. Create 2 files First (New-file):
File One: Name:
Messagebundle_de.properties
File Two: Name:
Messagebundle_zn.properties
1 PackageCHAP2;2 3 ImportJava.util.*;4 5 Public classTestlocale {6 Public Static voidMain (String args[]) {7Locale l1=NewLocale ("de", "de");8ResourceBundle rb1=resourcebundle.getbundle ("CHAP2. Messagebundle ", L1);9System.out.println (rb1.getstring ("message")); TenLocale l2=NewLocale ("Zn", "Zn"); OneResourceBundle rb2=resourcebundle.getbundle ("CHAP2. Messagebundle ", L2); ASystem.out.println (rb2.getstring ("message")); - - } the}
Note: ResourceBundle rb1=resourcebundle.getbundle ("CHAP2. Messagebundle ", L1);
To write: "CHAP2. Messagebundle "
Java--niit-ch2--location Localization Issues