Which statement defines a new Dateformat object that displays the default date format for the UK Locale?

Given the code fragment:
DateFormat df;
Which statement defines a new Dateformat object that displays the default date format for the UK
Locale?

Given the code fragment:
DateFormat df;
Which statement defines a new Dateformat object that displays the default date format for the UK
Locale?

A.
df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK));

B.
df = DateFormat.getDateInstance (DateFormat.DEFAULT, UK);

C.
df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK);

D.
df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK);

E.
df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK));

Explanation:

The UK locale is constructed withLocale.UK.
To format a date for a different Locale, specify it in the call to getDateInstance(). DateFormat df =
DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
Note: getDateInstance( int style, Locale aLocale )
Gets the date formatter with the given formatting style for the given locale.
Reference:Class DateFormat



Leave a Reply 1

Your email address will not be published. Required fields are marked *