Java DateFormatSymbols getInstance() Example
DateFormatSymbols class getInstance() method example. This example shows you how to use getInstance() method.
Syntax is : public static final DateFormatSymbols getInstance(Locale locale)
Method returns the DateFormatSymbols instance for the specified locale. This method provides access to DateFormatSymbols instances for locales supported by the Java runtime itself as well as for those supported by installed DateFormatSymbolsProvider implementations.
Here is the code.
/**
* @(#) GetInstance1DateFormatSymbols.java
* A class representing use of method getInstance() of DateFormatSymbols
class in java.text Package.
* @Version 14-May-2008
* @author Rose India Team
*/
import java.util.*;
import java.text.*;
class GetInstance1DateFormatSymbols {
public static void main(String[] args) {
// Create new DateFormatSymbols object with getInstance(Locale) method.
DateFormatSymbols dFormatSymbols = DateFormatSymbols.getInstance
(Locale.ENGLISH);
String[] weekDays = dFormatSymbols.getWeekdays();
System.out.print("Week days of date format for specified locale :");
for (int i = 0; i < weekDays.length; i++) {
System.out.println(weekDays[i]);
}
}
} |
Output of the program.
Week days of date format for specified locale :
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday |
|