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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -