![Java Internationalization Tutorial](/java_i18n/images/java_i18n-mini-logo.jpg)
- Java Internationalization Tutorial
- Java I18N - Home
- Java I18N - Overview
- Java I18N - Environment Setup
- Locale Class Examples
- Java I18N - Locale Class
- Java I18N - Locale Details
- Java I18N - Display Language
- ResourceBundle Class Examples
- Java I18N - ResourceBundle Class
- NumberFormat Class Examples
- Java I18N - NumberFormat Class
- Java I18N - Format Currencies
- Java I18N - Format Percentages
- Java I18N - Set Min/Max Precision
- Java I18N - Set Rounding Mode
- Java I18N - Parsing Numbers
- DecimalFormat Class Examples
- Java I18N - DecimalFormat Class
- Java I18N - Formatting Patterns
- Java I18N - Locale Specific DecimalFormat
- Java I18N - DecimalFormatSymbols Class
- Java I18N - Grouping Digits
- DateFormat Class Examples
- Java Java - DateFormat Class
- Java I18N - Formatting Dates
- Java I18N - Formatting Time
- Java I18N - Formatting Date and Time
- SimpleDateFormat Class Examples
- Java I18N - SimpleDateFormat Class
- Java I18N - Formatting Date
- Java I18N - DateFormatSymbols Class
- Java I18N - Date Format Patterns
- Time Zones Examples
- Java I18N - UTC
- Unicode Conversion
- Java I18N - From and To String Conversion
- Java I18N - From Reader and To Writer Conversion
- Related Tutorials
- Java Tutorial
- JDBC Tutorial
- SWING Tutorial
- AWT Tutorial
- Servlets Tutorial
- JSP Tutorial
- Java I18N Useful Resources
- Java I18N - Quick Guide
- Java I18N - Useful Resources
- Java I18N - Discussion
Java Internationalization - Locale specific Formatting Date
Locale can be used to create locale specific formatting over a pattern in SimpleDateFormat class. See the following example of using locale specific SimpleDateFormat class.
Example
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class I18NTester { public static void main(String[] args) throws ParseException { Locale locale = new Locale("da", "DK"); String pattern = "EEEEE MMMMM yyyy"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); Date date = new Date(); System.out.println(date); System.out.println(simpleDateFormat.format(date)); simpleDateFormat = new SimpleDateFormat(pattern,locale); System.out.println(simpleDateFormat.format(date)); } }
Output
It will print the following result.
Fri Jun 07 15:02:27 IST 2024 Friday June 2024 fredag juni 2024
Advertisements