目前位置:首页 > 学习园地 > 教学文章
 
  在职人员我要充电
    大学生摆脱低薪困扰
  高中毕业我要就业
 女孩子做IT白领
学习园地
教学文章
学员作品
 

开班信息
 
 

免费讲座
 

名企专家青鸟讲坛之十
主题:高考生的选择
主讲:北大青鸟资深职业规划师

时间:2008年7月5号
      下午2:00
电话:025-84200066       025-84200236

 

友情链接
  北大青鸟集团
印度APTECH公司
北大青鸟APTECH公司
北京大学
中兴软创
中国软件开发网
南京市科技技术局
江苏人事人才网
南京市人才市场
中国南京软件
青鸟教育e-Learning
 
 ◆ 教学文章
使用StopWatch类输出时间戳

package com.generationjava.test;

/**

* Useful when doing timings in a debug or test situation.

*/

public class StopWatch {

static public int AN_HOUR = 60 * 60 * 1000;

static public int A_MINUTE = 60 * 1000;

private long startTime = -1;

private long stopTime = -1;

/**

* Start the stopwatch.

*/

public void start() {

this.startTime = System.currentTimeMillis();

}

/**

* Stop the stopwatch.

*/

public void stop() {

this.stopTime = System.currentTimeMillis();

}

/**

* Reset the stopwatch.

*/

public void reset() {

this.startTime = -1;

this.stopTime = -1;

}

/**

* Split the time.

*/

public void split() {

this.stopTime = System.currentTimeMillis();

}

/**

* Remove a split.

*/

public void unsplit() {

this.stopTime = -1;

}

/**

* Get the time on the stopwatch. This is either the

* time between start and latest split, between start and stop,

* or the time between the start and the moment this method is called.

*/

public long getTime() {

if(stopTime != -1) {

return (System.currentTimeMillis() - this.startTime);

} else {

return this.stopTime - this.startTime;

}

}

public String toString() {

return getTimeString();

}

/**

* Get the time gap as a String.

* In hours, minutes, seconds and milliseconds.

*/

public String getTimeString() {

int hours, minutes, seconds, milliseconds;

long time = getTime();

hours = (int) (time / AN_HOUR);

time = time - (hours * AN_HOUR);

minutes = (int) (time / A_MINUTE);

time = time - (minutes * A_MINUTE);

seconds = (int) (time / 1000);

time = time - (seconds * 1000);

millis = (int) time;

return hours + "h:" + minutes + "m:" + seconds + "s:" + millis + "ms";

}

}

网站导航  使用帮助  招聘信息  联系我们  中心地图  在线留言
   
  ©版权所有2007 北大青鸟APTECH(南京迅超)授权培训中心
地址:南京市白下区建邺路66号3层
电话:025-84200066
传真:025-84200239 
网址:www.njaccp.com 
邮箱:accp@njaccp.com