I use System.currentTimeMillis () to save user startup time for activity.
public class TimeStamp {
protected long _startTimeMillis = System.currentTimeMillis();
public String getStartTime() {
return new Time(_startTimeMillis).toString();
}
the class is created when the activity starts, and getStartTime () returns the correct time. I am also trying to get the time elapsed after the action has been started.
public String getElapsedTime() {
return new Time(System.currentTimeMillis() - _startTimeMillis).toString();
}
This works great using an emulated Android device (android 4.0.3). But when I deploy the application on my real Android device (android 4.0.3), getElapsedTime () starts with one extra hour, and then it counts fine. So, on my real device, getElapsedTime () will return “01:00:01” after the action has been started, but it should return “00:00:01".
Do you have any idea why this is happening?