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

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


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

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

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

In this example, you will see the use of getDate() method of java Date class. It returns the day of the month for the specified date object, the value of  according to local time. The value returned is between 1 and 31 representing the day of the month.

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.getDate());
    }
}
Output
Current Date of system :2010-11-25
Day of given date : 25

Download this code.

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics