Hello!
I need to create a stopwatch. All I need is to have a button to start
and a button to stop, the start button click event will capture a time/
timestamp, the stop button event will capture another one. all I have
to do is to subtract both imes and show it like "hh:mm:ss". I guess it
must be quite easy, but I'm having so much problems. Here's a resume
of my code:
---------------------------------------------
//In the start event
Date start = new Date();
...
//In the stop event
Date stop = new Date();
// When showing the time
Date result = new Date(stop.getTime() - start.getTime());
DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("hh:mm:ss");
Window.alert(dateTimeFormat.format(result));
---------------------------------------------
It doesn't work. I tried with long values instead of Dates...
---------------------------------------------
//In the start event
long start = System.currentTimeMillis();
...
//In the stop event
long stop = System.currentTimeMillis();
// When showing the time
long result = stop - start;
Window.alert(long);
---------------------------------------------
Both ways I got crazy results... Please, can anybody help me? Thank
you very much.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---