📄 timewatch.java
字号:
package org.webdocwf.util.loader;
/**
* <p>Title: TimeWatch.java</p>
* <p>Description: Time measuring of importDefinitions </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Together</p>
* @author Sinisa Milosevic sinisa@prozone.co.yu
* @version 1.0
*/
/**
Copyright (C) 2002-2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Date;
/**
* Class used for calculating time.
*
* @author Sinisa Milosevic
* @version 1.1
*/
public class TimeWatch {
private long startTime = 0;
private long startJobTime = 0;
/**
* Constructor
*/
public TimeWatch() {
this.startJobTime=0;
this.startTime=System.currentTimeMillis();
}
/**
* Method getTotalTime - return all jobs duration as a String (min:sec,milsec)
* @return String (min:sec,milsec)
*/
public String getTotalTime() {
long currentTime = System.currentTimeMillis();
long difference = currentTime-this.startTime;
if(difference>60000){
long minutes = difference/60000;
long remainder = difference%60000;
return new String((new Long(minutes)).toString()+" minutes "+
(new Long(remainder/1000)).toString()+","+(new Long(remainder%1000)).toString()+" seconds");
}
else if(currentTime>1000)
return new String((new Long(difference/1000)).toString()+","+(new Long(difference%1000)).toString()+" seconds");
else
return new String((new Long(difference)).toString() +" miliseconds"); }
/**
* Method setStartJobTime - set time counter for new loader job
*/
public void setStartJobTime() {
this.startJobTime = System.currentTimeMillis();
}
/**
*Method setStartTime - set time counter for all loader jobs
*/
public void setStartTime() {
this.startTime = System.currentTimeMillis();
}
/**
* Method getJobTime - return duration of loader job (importDefinition or sql) as a String (min:sec,milsec)
* @return (min:sec,milsec)
*/
public String getJobTime() {
// DateFormat df = new SimpleDateFormat("mm:ss");
long currentTime = System.currentTimeMillis();
long difference = currentTime-this.startJobTime;
if(difference>60000){
long minutes = difference/60000;
long remainder = difference%60000;
return new String((new Long(minutes)).toString()+" minutes "+
(new Long(remainder/1000)).toString()+","+(new Long(remainder%1000)).toString()+" seconds");
}
else if(currentTime>1000)
return new String((new Long(difference/1000)).toString()+","+(new Long(difference%1000)).toString()+" seconds");
else
return new String((new Long(difference)).toString() +" miliseconds");
}
/**
* set jop time to 0.
*/
public void reset() {
this.startJobTime=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -