java - Chronometer doesn't start from 00:00:00 -
i have problem chronometer. when start it, begins 01:00:00. don't know why. think code correct.
can understand problem is?
this code:
chronometer crono = new chronometer(this); crono.setbase(systemclock.elapsedrealtime()); crono.start();
when print time call method:
long time = systemclock.elapsedrealtime() - totaltime.getbase(); date date = new date(time); simpledateformat formatter = new simpledateformat("hh:mm:ss"); formatter.format(date);
thanks much!
you're trying format date difference date. i'd maybe timezones come play?
scala> new java.util.date(0) res2: java.util.date = thu jan 01 01:00:00 gmt 1970 scala> new simpledateformat("hh:mm:ss").format(new date(0)) res5: string = 01:00:00
you might want [durationformatutils.formatduration()
](http://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/durationformatutils.html#formatduration(long, java.lang.string)).
Comments
Post a Comment