Date.getTime question

I have the following code. Why do I only get the same output? Pls help. I'd like to get a timestamp diff.

Date thisMoment1 = new Date();

System.out.println("Start Time: " + thisMoment1.getTime());

Thread.sleep(5000);

System.out.println("EndTime: " + thisMoment2.getTime());

output:

Start Time: 997223951609

EndTime: 997223951609

[385 byte] By [LearnJ] at [2007-9-26 3:18:44]
# 1
You need to addDate thisMoment2 = new Date(); just after the call to sleep()
nerd2004 at 2007-6-29 11:33:04 > top of Java-index,Archived Forums,Java Programming...
# 2
You could also try System.currentTimeMillis() This is a static method, so you don't have to create any new objects.
hungyee at 2007-6-29 11:33:04 > top of Java-index,Archived Forums,Java Programming...
# 3
Since you never declared thisMoment2, I'm surprised your code compiled.Rich
rmiller1985 at 2007-6-29 11:33:04 > top of Java-index,Archived Forums,Java Programming...