android中获取某段程序的执行时间

Date   startDate   =   new   Date(System.currentTimeMillis());

在收到设备返回数据之后添加如下语句:

Date   endDate   =   new   Date(System.currentTimeMillis());

long diff = endDate.getTime() - startDate.getTime();

然后在文本框中显示出来:

String sDiff = String.valueOf(AmoComActivity.Diff);  
((TextView) findViewById(R.id.edit_text)).setText(sDiff);

posted @ 2017-11-02 12:08  鸭子船长  阅读(2393)  评论(0编辑  收藏  举报