Use of getDay() method of Date class in java.

Use of getDay() method of Date class in java.


Posted in : Core Java Posted on : November 25, 2010 at 5:48 PM Comments : [ 0 ]

In this example, you will see the use of getDay() method of Date class in java.

Use of getDay() method of Date class in java.

In this example, you will see the use of getDay() method of java date class. It returns day of  week for the given date. The value is 0=Sunday 1=Monday 2= Tuesday 3=Wednesday  4=Thursday 5=Friday 6=Saturday.

Code:

import java.text.SimpleDateFormat;
import java.util.Date;

public class GetDateMethod {
  public static void main(String[] args) {
	Date obDate = new Date();
	SimpleDateFormat obDateFormat = new SimpleDateFormat("yyyy-MM-dd");
	System.out.println("Current Date of system :"
		+ obDateFormat.format(obDate.getTime()));
	System.out.println("Day of given date : " + obDate.getDay());
    }
}
Output
Current Date of system :2010-11-25 04:11:25 PM
Hours of given date : 4

Download this code.

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics