Home Tutorials I18N Change Week Days Format



Change Week Days Format
Posted on: September 13, 2008 at 12:00 AM
This Example shows you how to change week days format. In the code given below we are change week days format.

Change Week Days Format

     

This Example shows you how to change week days format. In the code given below we are change week days format.

Methods used in this example are described below :

DateFormatSymbols() : DateFormatSymbols class object used for formatting localizable date-time. It format the months name and days name.

DateFormatSymbols.getShortWeekdays() : getShortWeekdays method returns a string type array and this array have shorted weekdays, For example: "Sun", "Mon", "Tue" etc.

DateFormatSymbols.setShortWeekdays() : setShortWeekdays method is used to set weekday in short format, For example: "Sun", "Mon", etc.

ChangeWeekDays.java



import java.text.*;
import java.util.*;

public class ChangeWeekDays {

  public static void main(String args[]) {
  Date today;
  String result;
  SimpleDateFormat formatter;
  DateFormatSymbols symbols;
  String[] defaultDays;
  String[] modifiedDays;

 symbols = new DateFormatSymbols(new Locale("en""US"));
 defaultDays = symbols.getShortWeekdays();

 for (int i = 0; i < defaultDays.length; i++) {
  System.out.print(defaultDays[i"  ");
 }
 System.out.println();

 String[] capitalDays = 
   {
"""SUN""MON""TUE""WED""THU""FRI","SAT"};
 
symbols.setShortWeekdays(capitalDays);

 modifiedDays = symbols.getShortWeekdays();
  for (int i = 0; i < modifiedDays.length; i++) {
  System.out.print(modifiedDays[i"  ");
  }

  System.out.println();
  System.out.println();

  formatter = new SimpleDateFormat("E", symbols);
  today = new Date();
  result = formatter.format(today);
  System.out.println("Today is : "+result);
  }
}

Output : Output :

  Sun  Mon  Tue  Wed  Thu  Fri  Sat  
  SUN  MON  TUE  WED  THU  FRI  SAT  

Today is : TUE

Download code Download code

     

Related Tags for Change Week Days Format:
cormformformatchangethisshowforexampletoexamwsshehanginrmmweekhowdayxaxampseedaysatkishaivmplarcodcodessthshobelopleplodeo


More Tutorials from this section

Ask Questions?    Discuss: Change Week Days Format  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.