All Flashcards
Can ListResourceBundles class be private or protected?
No it must be public, due to reflection.
The key name is a case sensitive in resource bundle and must exactly match?
Yes
A fully qualified Resource Bundle has the following name…
packagequalifier.bundlename + “” + language + “” + country + “” + (variant + “#” | “#”) + script + “-“ + extensions
like localization.examples.AppBundle_en_US_Oracle_exam
The getBundle() method takes a ResourceBundle.Control object as an additional parameter. By extending this ResourceBundle.Control class and passing the instance of that extended class to the getBundle() method, you can change the default resource bundle search process or read from non-standard resource bundle formats (such as XML files
Yes
If the locale of the ResourceBundle.getLocale() name is empty, it means Java has loaded the global resource bundle
Yes
NumberFormat and DateFormat—are both inherited from the Format base class; these classes are part of the java.text package and are useful for making locale-aware software
Yes
When using NumberFormat to parse Strings we must caught…
ParseException
What is the difference between parse() method from the format() method of Format class
The parse() method is meant for reading numbers provided as String and trying to convert it to Number. The format() method is used for printing the values according to the values set in the NumberFormat object.
How can we specify the fraction digits in NumberFormat?
numberFormat.setMaximumFractionDigits(2)
Important Methods in the NumberFormat Class
String format(double number) String format(long number) Number parse(String source) static Locale[] getAvailableLocales() static NumberFormat getInstance() Currency getCurrency() static NumberFormat getCurrencyInstance() static NumberFormat getIntegerInstance() static NumberFormat getPercentInstance()
Important Methods in the DateFormat Class
String format(Date date) Date parse(String source) String format(Date date) static Locale[] getAvailableLocales() static DateFormat getInstance() static DateFormat getDateInstance() static DateFormat getTimeInstance() static DateFormat getDateTimeInstance()
Which are the available style formats of DateFormat class?
DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG, DateFormat.FULL, DateFormat.DEFAULT
The DateFormat has three overloaded factory methods…
getDateInstance(), getTimeInstance(), and getDateTimeInstance()
If you want to create your own format or pattern for processing the date or time, can you do that?
Yes, the SimpleDateFormat class provides this facility.
Here is the list of important letters and their meanings for creating patterns for dates…
G Era (BC/AD) y Year Y Week year M Month (in year) w Week (in year W Week (in month) D Day (in year) d Day (in month) F Day of week in month E Day name in week u Day number of week
There are many ways to get or create a Locale object…
Option 1: Use the constructor of the Locale class: Locale(String language, String country, String variant): Locale locale1 = new Locale(“it”, “”, “”);
Option 2: Use the forLanguageTag(String languageTag) method in the Locale class: Locale locale2 = Locale.forLanguageTag(“it”);
Option 3: Build a Locale object by instantiating Locale.Builder and then call setLanguageTag() from that object: Locale locale3 = new Locale.Builder().setLanguageTag(“it”).build();
Option 4: Use the predefined static final constants for locales in the Locale class: Locale locale4 = Locale.ITALIAN