In java applications, we are able to provide I18N Supported in the form of the following 3 areas.
1.Number formations
To prepare number format class object, we have to use the following static factory method public static number format get instance(Local l) 2.Format a number w.r.to a local To format number, we have to use the following method public string format(XXX NUMBER)Where xxx may be byte, short, int, float,… Import java. Text*; Import java. util*; Public class Test { Public static void main(strin[]args) throws exception { Local l=new local(“it”,”It”); Number format nf=number format. Get instance(l); s.o.p(nf.format(12345.234567)); } }
If we want to represent date w.r.to a particular local. We have to use a predefined class java.text. date formal
Local i= new locale(“en”,”us”);
To create data format object, we have to use the following static factory method. Public static data format get data insurance (int data- sty, local i)
To represent data. W.r.t the specified local, public string format(date d) àImport java. text.*; Import java. util.*; Public class test { p.s.v.m() throws exception { Locale l=new locale(“It”,”IT”); Data format dt= Date format. Get date insurance.col); s.o.p(dt. format; new date()))); } }
To represent a message w.r.to a particular local we have to use a predefined class provided by java java. util. Resource bundle It we want to use resource bundle in java application we have to use the following steps
To prepare properties files we have to take a text file and provide locale messages in the from of key- value pairs and we must save properties file with the following naming conversion <base-name>-<long>-<country><sys-var>. prepare files Abc-en-us. Properties Uname= user name Upwd= password
Local I = new locale(“en”,”us”);
To prepare resource bundle class object we have to use the following static factory method public static resource bundle[string base – name locale()
To get a message on the basis of a key, we have to use the following method public string get string(string key) Abc-en-us. Properties Welcome=welcome to en us users Abc –it IT Properties Welcome=welcome to it It USERS. Public class test { p.S.V.M()THROWS Exception { Locate I = new locale(“it”,”IT”); Resource bundle rb = resourceBundle. GetBundle(“abc”,i); s.o.p(rb. get string(“welcome”)); } }
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.