国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

使用StopWatch類輸出時(shí)間戳

2019-11-17 06:00:06
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

}

}

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武义县| 田林县| 运城市| 萍乡市| 龙山县| 阿克苏市| 旬邑县| 通道| 乳山市| 乐东| 平乡县| 姚安县| 镇赉县| 调兵山市| 南涧| 吉隆县| 陵水| 红原县| 丹寨县| 曲沃县| 云龙县| 怀仁县| 定边县| 闻喜县| 汝南县| 南乐县| 壶关县| 五河县| 东平县| 商河县| 台山市| 陇川县| 丰台区| 志丹县| 来宾市| 河源市| 镶黄旗| 九龙坡区| 洛扎县| 孙吴县| 台江县|