java - Format milliseconds to simpledate format -


i'm facing weird result when formatting milliseconds simpledate format:

output is:

    start date time: 11/06/30 09:45:48:970     end date time: 11/06/30 09:45:52:831     execution time: 01:00:03:861 

script:

    long datetimestart = system.currenttimemillis();         // script execution here     long datetimeend = system.currenttimemillis();      "start date time: " + globalutilities.getdate(datetimestart, "yy/mm/dd hh:mm:ss:sss");      "end date time: " + globalutilities.getdate(datetimeend, "yy/mm/dd hh:mm:ss:sss");      "execution time: " + globalutilities.getdate((datetimeend - datetimestart), "hh:mm:ss:sss"); 

method:

    public static string getdate(long milliseconds, string format)     {         simpledateformat sdf = new simpledateformat(format);         return sdf.format(milliseconds);     } 

any idea why execution time value off? should 00:00:03:861, not 01:00:03:861

thanks

the execution time off because date constructor takes long specifying number of milliseconds since 1970-01-01.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -