Home Java Javadate Day Format Example
Questions:Ask|Latest



Day Format Example
Posted on: October 13, 2008 By Deepak Kumar
This example shows how to format day using Format class. In this program we use a pattern of special characters to day format.

Day Format Example

     

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

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.

DayFormat.java

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

public class DayFormat {

ffff">  public static void main(String args[]) {

  String s;
  Format formatter;
  Date date = new Date();
  date.setDate(9);

  formatter = new SimpleDateFormat("d")// 9
  s = formatter.format(date);
  System.out.println("Date : " + s);

  formatter = new SimpleDateFormat("dd");  // 09
  s = formatter.format(date);
  System.out.println("Date : " + s);
  }
}


Output

Date : 9
Date : 09

Download code

Recommend the tutorial

Ask Questions?    Discuss: Day Format Example  

Post your Comment


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