More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

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

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Join and Excel yourself with our Online instructor led training sessions
Training Courses
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.