3:06 pm - Wednesday September 26, 3235

Calendar in java example program getTimeInMillis()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
*@author: candidjava
*@description: Calendar in java example program for getTimeInMillis()
**/
import java.util.Calendar;

public class CalendarDem {
public static void main(String[] args) throws InterruptedException {
// create a calendar
Calendar cal = Calendar.getInstance();
// print current time in milliseconds
System.out.println("Current time is : " + cal.getTimeInMillis());
// add a delay of 2 seconds
Thread.sleep(2000);
// create a new calendar
Calendar cal2 = Calendar.getInstance();
// print the next time in milliseconds
long d = cal2.getTimeInMillis();
System.out.println("Next time is : " + d);
}
}

Output:

Current time is : 1350330105015
Next time is : 1350220107031

BACK

Filed in: Z-A All Java Codes

Comments are closed.