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

Given the code fragment:

DataFormat df;

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

Given the code fragment:

DataFormat df;

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

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

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

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

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

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

Explanation:
The UK locale is constructed withLocale.UK.
Example:
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 3

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


mohamed kasmi

mohamed kasmi

since java is casesensitive, are all the given answer not correct.
the correct answer is:
DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.UK);

Also the method is getDateInstance and not getdatDataInstance

Joseph

Joseph

DateFormat df 已寫在題目上了…