Class DateFormatSymbols in Java

digitization, transformation, binary

Class DateFormatSymbols in Java

The DateFormatSymbols class encapsulates date and time formatting data that is locale-specific, like the names of the days of the week and the names of the months. Typically, you do not need to instantiate DateFormatSymbols yourself. Instead, an instance is automatically created for us, behind the scenes, when we use one of the factory methods in DateFormat to create a DateFormat object.

We can retrieve a DateFormatSymbols object by calling the getDateFormatSymbols() method of SimpleDateFormat. Once we have a DateFormatSymbols object, we can modify
the strings it uses if you want to change them.

Ads code goes here

The structure of the class DateFormatSymbols is given by

public class java.text.DateFormatSymbols extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable {
// Constructors
public DateFormatSymbols();
public DateFormatSymbols(Locale locale);
// Instance Methods
public Object clone();
public boolean equals(Object obj);
public String[] getAmPmStrings();
public String[] getEras();
public String getLocalPatternChars();
public String[] getMonths();
public String[] getShortMonths();
public String[] getShortWeekdays();
public String[] getWeekdays();
public String[][] getZoneStrings();
public int hashCode();
public void setAmPmStrings(String[] newAmpms);
public void setEras(String[] newEras);
public void setLocalPatternChars(String newLocalPatternChars);
public void setMonths(String[] newMonths);
public void setShortMonths(String[] newShortMonths);
public void setShortWeekdays(String[] newShortWeekdays);
public void setWeekdays(String[] newWeekdays);
public void setZoneStrings(String[][] newZoneStrings);
}

The details of the class structure are given as follows:

public DateFormatSymbols();

public DateFormatSymbols() constructor creates a DateFormatSymbols object for the default locale.

public DateFormatSymbols(Locale locale);

public DateFormatSymbols(Locale locale) constructor creates a DateFormatSymbols object for the given locale.

Parameter
locale – The Locale to use.

public Object clone();

public Object clone() method creates a copy of this DateFormatSymbols and returns it.

READ  Learn Methods in Java in a Quick Manner

This method returns a copy of this DateFormatSymbols.

public boolean equals(Object obj);

public boolean equals(Object obj) method returns true if obj is an instance of DecimalFormatSymbols and is equivalent
to this DateFormatSymbols.

This method returns true if the objects are equal; false if they are not.

Parameter
obj – The object to be compared with this object.

public String[] getAmPmStrings();

public String[] getAmPmStrings() method returns the strings that are used for the A.M./P.M. field (e.g., “AM”, “PM”).

This method returns an array of strings used for the A.M./P.M. field for this DateFormatSymbols.

public String[] getEras();

public String[] getEras() method returns the strings that are used for the era field (e.g., “BC”, “AD”).

This method returns an array of strings used for the era field for this DateFormatSymbols

public String getLocalPatternChars();

public String getLocalPatternChars() method returns the data-time pattern characters for the locale of this object.

This method returns a string that contains the data-time pattern characters for this DateFormatSymbols.

public String[] getMonths();

public String[] getMonths() method returns the strings that are used for the month field (e.g., “January”, “February”).

This method returns an array of strings used for the month field for this DateFormatSymbols.

public String[] getShortMonths();

public String[] getShortMonths() method returns the strings that are used for the short (i.e., three-character) month field (e.g., “Jan”, “Feb”).

This method returns an array of strings used for the short month field for this DateFormatSymbols.

public String[] getShortWeekdays();

public String[] getShortWeekdays() method returns the strings that are used for the short (i.e., three-character) weekday field (e.g.,”Mon”, “Tue”).
This method returns an array of strings used for the short weekday field for this DateFormatSymbols.

public String[] getWeekdays();

public String[] getWeekdays() method returns the strings that are used for the weekday field (e.g., “Monday”, “Tuesday”).

READ  How To Set Classpath in Java

This method returns an array of strings used for the weekday field for this DateFormatSymbols.

public String[][] getZoneStrings();

public String[][] getZoneStrings() method returns the time-zone strings. Each subarray is an array of six strings that specify a time-zone ID, its long name, its short name, its daylight-savings-time name, its short daylight-savings-time name, and a major city in the time zone. For example, an entry for Mountain Standard Time is:

{“MST”, “Mountain Standard Time”, “MST”,”Mountain Daylight Time”, “MDT”, “Denver”}

This method returns an array of arrays of strings used for the time zones for this DateFormatSymbols.

public int hashCode();

public int hashCode() method returns a hashcode for this DateFormatSymbols object.

This method returns a hashcode for this object.

public void setAmPmStrings(String[] newAmpms);

public void setAmPmStrings(String[] newAmpms) method sets the strings that are used for the A.M./P.M. field for this DateFormatSymbols.

Parameter
newAmpms – The new strings.

public void setEras(String[] newEras);

public void setEras(String[] newEras) method sets the strings that are used for the era field for this DateFormatSymbols.

Parameter
newEras – The new strings.

public void setLocalPatternChars(String newLocalPatternChars);

public void setLocalPatternChars(String newLocalPatternChars) method sets the date-time pattern characters of this DateFormatSymbols object.

Parameter
newLocalPatternChars – The new date-time pattern characters.

public void setMonths(String[] newMonths);

public void setMonths(String[] newMonths) method sets the strings that are used for the month field for this DateFormatSymbols.

Parameter
newMonths – The new strings.

public void setShortMonths(String[] newShortMonths);

public void setShortMonths(String[] newShortMonths) method sets the strings that are used for the short (i.e., three-character) month field for this DateFormatSymbols.

Parameter
newShortMonths – The new strings.

public void setShortWeekdays(String[] newShortWeekdays);

public void setShortWeekdays(String[] newShortWeekdays) method sets the strings that are used for the short (i.e., three-character) weekday field for this DateFormatSymbols.
This method returns
Parameter
newShortWeekdays – The new strings.

public void setWeekdays(String[] newWeekdays);

public void setWeekdays(String[] newWeekdays) method sets the strings that are used for the weekday field for this DateFormatSymbols.

READ  Class NoRouteToHostException in Java

Parameter
newWeekdays – The new strings.

public void setZoneStrings(String[][] newZoneStrings);

public void setZoneStrings(String[][] newZoneStrings) method sets the strings that are used for the time-zone field for this DateFormatSymbols.

Parameter
newZoneStrings – The new strings.

Apart from these DateFormatSymbols class also has inherited methods from class- Object. They are as follows:

  • finalize()
  • notifyAll()
  • wait()
  • wait(long, int)
  • getClass()
  • notify()
  • toString()
  • wait(long)

Share and Enjoy !

Leave a Comment

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