File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes milliseconds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "milliseconds" Watch "milliseconds" New topic
Author

milliseconds

Jelle Paelman
Greenhorn

Joined: Feb 08, 2001
Posts: 2
Hi,
Is there anyway to get the exact milliseconds of the time.
The result i got with the code below is mostly the same and sometimes 10 milliseconds more, but never just 1 millisecond(which i need to make a unique code and not lose to much time)
Apparently it never changes the milliseconds but only every ten milliseconds.
for (int i = 0; i <50; i++)
{
try { Thread.sleep(1); }
catch (InterruptedException e) {}
System.out.println(System.currentTimeMillis()) ;
}
Hope someone can help me,
Jelle
Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
This is some code from a CORBA app I wrote that returns the date with milliseconds. If you create a calendar, you should be able to pull the current time out, like so:


There's nothing more dangerous than a resourceful idiot. ---Dilbert
Jelle Paelman
Greenhorn

Joined: Feb 08, 2001
Posts: 2
Still don't work, i still need a 10 millisecond delay(Thread.sleep(10)) to get a unique code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: milliseconds