![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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.
Advertisements