Java Calendar.setTimeInMillis(long millis)
Syntax
Calendar.setTimeInMillis(long millis) has the following syntax.
public void setTimeInMillis(long millis)
Example
In the following code shows how to use Calendar.setTimeInMillis(long millis) method.
/*from w w w .ja va2 s.c o m*/
import java.util.Calendar;
public class Main {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
// get the time in milliseconds
System.out.println("Current time is :" + cal.getTime());
// set time to 5000000000 ms after january 1 1970
cal.setTimeInMillis(5000000000L);
// print the new time
System.out.println("After setting Time: " + cal.getTime());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »