Home Java Javadate Week Days Format Example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Week Days Format Example

Advertisement
This example shows how to format week days using Format class. In this program we use a pattern of special characters to format week day.

Week Days Format Example

     

This example shows how to format week days using Format class. In this program we use a pattern of special characters to format week day.

Description of the code :

SimpleDateFormat() : SimpleDateFormat class use for formatting and parsing dates. It allows for formatting date into text , parsing text into date and normalization.

format() : This method used for format Date class object into date / time and appends the it into the StringBuffer.

SecondFormat.java


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

public class WeekFormat {

  public static void main(String args[]) {

  String s;
  Format formatter;
  Date date = new Date();

  formatter = new SimpleDateFormat("E")// Wed
  s = formatter.format(date);
  System.out.println("Day : " + s);

  formatter = new SimpleDateFormat("EEEE");  // Wednesday
  s = formatter.format(date);
  System.out.println("Day : " + s);
  }
}


Output

Day : Sat
Day : Saturday

Download code
Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 13, 2008

Ask Questions?    Discuss: Week Days Format Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com