SCJP Certification

Sun Certified Java Programmer Certification exam essentials

November 27th, 2009

What are the getTime() and setTime() method?

Java Facts, by Daisy Williams.

getTime(): The getTime() method returns a date/time of the calendar in a Date object. Date objects are stored as an offset in milliseconds. The general form of the getTime() method is as follows:

Date getTime()

e.g. System.out.println(calendar.getTime());

setTime(): The setTime() method sets the current calendar’s date/time from the value of the specified date. The general form of the setTime() method is as follows:

void setTime(Date date)

e.g. calendar.setTime(date2);

Share

Back Top

Responses to “What are the getTime() and setTime() method?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*