Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get current time in seconds

843785Oct 7 2008 — edited Oct 9 2008
Can someone please tell me how to get the current time in seconds. I am currently doing as follows but not sure if its correct or best way:

Calendar cal = new GregorianCalendar();
long currentTimeInSeconds = cal.getTimeInMillis()/1000;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 6 2008
Added on Oct 7 2008
39 comments
962 views