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);

原文地址:https://www.cnblogs.com/zl1991/p/7771603.html