Calendar setTimeInMillis() Method in Java with Examples
The setTimeInMillis(long mill_sec) method in Calendar class is used to set Calendars time represented by this Calendar from the passed long value.
public void setTimeInMillis(long mill_sec)
Parameters: The method takes one parameter mill_sec of long datat-type and refers to the given date that is to be set.
Return Value: The method does not return any value.
Below programs illustrate the working of setTimeInMillis() Method of Calendar class:
The Current Time is: Fri Feb 22 08:00:54 UTC 2019 After setting Time: Thu Jan 01 00:00:02 UTC 1970
The Current Time is: Fri Feb 22 08:01:02 UTC 2019 After setting Time: Thu Jan 01 00:00:08 UTC 1970
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.