Timestamp returned from getWhen()
Hi,
I am confused with the timestamp returned from getWhen(), while it seems that this timestamp is NOT retrieved in the same way as currentTimeMillis().
I have written a testing program, constructing an UI with only a button and adding some printout in actionPerformed:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
publicclass PressButton{
publicstaticvoid main(String args[]){
JFrame frame =new JFrame();
frame.setSize(200,200);
final JButton button =new JButton("Click Me!");
button.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
if (e.getSource() == button){
System.out.println(new Date(System.currentTimeMillis()));
System.out.println(new Date(e.getWhen()));
}
}
});
frame.getContentPane().add(button);
frame.setVisible(true);
}
}
When I run this program and press the button, both timestamps are equal. After that, I change the windows clock (say a day later) and press the button again. In this case, the timestamp returned from getWhen() is still the old day while that returned from currentTimeMillis() is a day later.
Is there a implementation difference in the JRE?
P.S. Java Version:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

