Javatpoint Logo
Javatpoint Logo

Java Calendar setTime() Method

The setTime () method of java.util.Calendar class is used to set the Time of current calendar object. A Date object id is passed as the parameter into this method.

Syntax

Parameter

date - a date object.

Returns

Does not return value.

Throws

Does not throw Exception.

Example 1

Test it Now

Output:

Date :Sat Nov 23 00:00:00 PST 1996
 new Date is :Sun Nov 10 00:00:00 PST 1918

Example 2

Test it Now

Output:

Date  (mycal):Wed Aug 15 19:07:31 PDT 2018
  Date (mycal2) :Mon Oct 14 19:07:31 PDT 1996




Help Others, Please Share

facebook twitter pinterest