Hi everybody,
I am new to Java, and wanted to add the CurrentTime into a small program...
I imported:
import java.util.Date;
public static void main(String[] args)
{
System.out.println("Current Time is: " + currentTime());
}
private static long currentTime()
{
Date date = new Date();
return date.getTime();
}
I tend to get a really long number...
Can anyone help me with that?
Thank you in advance
2007-02-21
09:02:09
·
1 answers
·
asked by
...Sky the Limits...
5
in
Computers & Internet
➔ Programming & Design
Amit:
Thanks a lot for the code...but the hours don't tend to work right - I get a wrong value
The minutes and seconds work perfectly...
This is the code I added:
System.out.println("Current Time is: " + (currentTime() % 86400000) / 3600000+ ":" + (currentTime() % 3600000) / 60000 + ":" + (currentTime() % 60000) / 1000);
2007-02-21
12:50:02 ·
update #1
It's working perfectly now...
I think the error was in the program I'm using or something...
Thanks a lot
2007-02-21
15:08:38 ·
update #2