The DateFormatSymbols
class (in java.text
) provides locale-specific data used by DateFormat
classes, such as:
- Month names
- Day names
- AM/PM markers
- Era strings
It allows customization of how date and time values are formatted or parsed.
Key Features:
- Helps
DateFormat
with textual date elements like months and days. - Locale-sensitive.
- Customizable for creating localized or specialized date formats.
Commonly Used Methods

Simple Program
import java.text.DateFormatSymbols; public class SimpleDateFormatSymbolsExample { public static void main(String[] args) { DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); System.out.println("Months of the Year:"); for (String month : months) { if (!month.isEmpty()) // last element is often empty System.out.println(month); } } }
Problem Statement
Paani and Mahesh are building a multilingual calendar application for a global audience. The challenge is to localize the display of months and weekdays in Spanish while keeping the rest of the app in English. They use DateFormatSymbols
to customize month and weekday names without changing the entire locale.
import java.text.*; import java.util.*; public class CustomSpanishCalendar { public static void main(String[] args) { // Custom Spanish month and weekday names String[] spanishMonths = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; String[] spanishWeekdays = { "", "Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado" }; DateFormatSymbols spanishSymbols = new DateFormatSymbols(Locale.ENGLISH); spanishSymbols.setMonths(spanishMonths); spanishSymbols.setWeekdays(spanishWeekdays); SimpleDateFormat sdf = new SimpleDateFormat("EEEE, d MMMM yyyy", spanishSymbols); Date today = new Date(); System.out.println("Fecha personalizada: " + sdf.format(today)); } } /* Fecha personalizada: Viernes, 23 Mayo 2025 */
The DateFormatSymbols
class in Java offers fine-grained control over textual components of dates for localization or customization usedÂ
- When customizing month/day names in a locale-aware date format.
- When building multi-language date UI without switching full locale.
- When building custom calendars or time displays.