- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to get display name for Day of Week in different locale
To get the display name for Day of Week in different locale, let us first get the default −
Locale locale = Locale.getDefault();
Now, let’s say we want to consider Canada locale −
Locale locale1 = Locale.CANADA;
Now, get the Day of Week name for locale default and Canada −
System.out.printf("%s%n", DayOfWeek.THURSDAY.minus(2).getDisplayName(TextStyle.SHORT, locale)); System.out.printf("%s%n", DayOfWeek.THURSDAY.minus(2).getDisplayName(TextStyle.SHORT, locale1));
Example
import java.time.DayOfWeek; import java.time.format.TextStyle; import java.util.Locale; public class Demo { public static void main(String[] args) { Locale locale = Locale.getDefault(); Locale locale1 = Locale.CANADA; System.out.printf("%s%n", DayOfWeek.THURSDAY.minus(2).getDisplayName(TextStyle.SHORT, locale)); System.out.printf("%s%n", DayOfWeek.THURSDAY.minus(2).getDisplayName(TextStyle.SHORT, locale1)); Locale locale2 = Locale.FRENCH; System.out.printf("%s%n", DayOfWeek.SUNDAY.minus(10).getDisplayName(TextStyle.SHORT, locale2)); } }
Output
Tue Tue. jeu.
- Related Articles
- Display Day Name of Week using Java Calendar
- Java Program to get day of week for the last day of each month in 2019
- Java Program to get day of week as string
- Get localized short day-in-week name in Java
- Get Day Number of Week in Java
- Java Program to get the day of the week from GregorianCalendar
- Get the week number in MySQL for day of week?
- C# Program to get current day of week
- Get the day of week for a particular date in Java
- Java Program to get full day name
- Java Program to display date with day name in short format
- How to get first day of week in PHP?
- Display the day in week using SimpleDateFormat('E') in Java
- Get localized day name in Java
- How to get the day of the week in JavaScript?

Advertisements