-1

How i get days of week (SUNDAY, MONDAY, TUESDAY etc.) as short format(SUN,MON,TUE etc.) for system locale in Android?

String mondayshort --> output:"MON"(for English) or "LUN"(for French)
String tuesdatshort --> output:"TUE"(for English) or "MAR"(for French)
String wednesdayshort --> output:"WED"(for English) or "MER"(for French)
Taha Körkem
  • 774
  • 2
  • 9
  • 23
  • 1
    Have you tried just using `SimpleDateFormat` and `MMM` as the format pattern? – Jon Skeet Dec 06 '14 at 09:51
  • can you write an example? – Taha Körkem Dec 06 '14 at 09:52
  • 6
    There are *lots* of examples of SimpleDateFormat on Stack Overflow, and in the documentation, and in numerous other pages on the web. I suggest you try it yourself first, and if you have problems you edit what you've tried (along with the expected result and the actual result) into the question. – Jon Skeet Dec 06 '14 at 09:53
  • @Joe i dont want current day. i want days of week for system locale – Taha Körkem Dec 06 '14 at 10:31
  • @JonSkeet: With all my respects... but isn't `MMM` used for formatting **months**? I guess the OP needs `EEE`, instead. Reference: http://developer.android.com/reference/java/text/SimpleDateFormat.html – Phantômaxx Dec 06 '14 at 10:39
  • 1
    @DerGolem: Yes, you're absolutely right - EEE is whats called for. Was too hasty. – Jon Skeet Dec 06 '14 at 10:40
  • 1
    @Taha: once you know how to do today's date, it's trivial to work put how to do another date. It's important to be learn to adapt code which does *some* of what you want. – Jon Skeet Dec 06 '14 at 10:42
  • @JonSkeet... **EPIC WIN**!! I corrected **JonSkeet**!!!! ;) – Phantômaxx Dec 06 '14 at 10:42
  • i dont want current day of week. i want get short character for days of week – Taha Körkem Dec 06 '14 at 10:43
  • 1
    Then simply add the **locale** in your SimpleDateFormat constructor: `SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);` Reference: http://developer.android.com/reference/java/text/SimpleDateFormat.html – Phantômaxx Dec 06 '14 at 10:48
  • 1
    @Taha: repeating your previous comment doesn't in any way address my response to it. – Jon Skeet Dec 06 '14 at 11:06
  • my string is "monday" "sunday" and i get short monday for system locale in "monday". i get short sunday for system locale in "sunday" can i get this strings? – Taha Körkem Dec 06 '14 at 11:08
  • 1
    What do you mean by "my string is"? What string? It's not at all clear what you're trying to do now. I've added an answer for what I *thought* you wanted, but that doesn't naturally have a string input... – Jon Skeet Dec 06 '14 at 11:10
  • example:String monday ----- in output, MON or LUN – Taha Körkem Dec 06 '14 at 11:14
  • 1
    It's still not clear whether you mean you've got a user *input* of "monday", or whether you're just declaring a string *variable* called monday. – Jon Skeet Dec 06 '14 at 11:23

2 Answers2

3

To format a specific date (not necessarily the current date), use EEE in a SimpleDateFormat. If you want all the short days of the week, you could use

DateFormatSymbols symbols = new DateFormatSymbols(locale);
String[] shortDays = symbols.getShortWeekdays();
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
1

Write EEEE for your requirement. If you need complete code tell me I will show you. :)

Biswajit
  • 1,829
  • 1
  • 18
  • 33