SimpleDateFormat getDateFormatSymbols() Method in Java with Examples
Last Updated :
30 Jan, 2019
The getDateFormatSymbols() Method of SimpleDateFormat class is used to return the copy of the date and time format symbols.
Syntax:
public DateFormatSymbols getDateFormatSymbols()
Parameters: The method does not take any parameters.
Return Value: The method returns a copy of the format symbols.
Below programs illustrate the working of getDateFormatSymbols() Method of SimpleDateFormat:
Example 1:
import java.text.*;
import java.util.*;
public class SimpleDateFormat_Demo {
public static void main(String[] args)
{
SimpleDateFormat SDFormat
= new SimpleDateFormat();
DateFormatSymbols DFSymbol
= SDFormat.getDateFormatSymbols();
String[] month = DFSymbol.getShortMonths();
System.out.println( "The Months are: " );
for ( int i = 0 ; i < month.length; i++) {
System.out.println(month[i] + " " );
}
}
}
|
Output:
The Months are:
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Example 2:
import java.text.*;
import java.util.*;
public class SimpleDateFormat_Demo {
public static void main(String[] args)
{
SimpleDateFormat SDFormat
= new SimpleDateFormat();
DateFormatSymbols DFSymbol
= SDFormat.getDateFormatSymbols();
String[] days = DFSymbol.getWeekdays();
System.out.println( "The days of the week are: " );
for ( int i = 0 ; i < days.length; i++) {
System.out.println(days[i] + " " );
}
}
}
|
Output:
The days of the week are:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...