📄 stoptime.java
字号:
package com.count.stoptime;
import java.util.*;
import java.text.*;
public class StopTime {
private int h=0;
private int m=0;
private int s=0;
private Date start=null;
private Date end=null;
private SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
public StopTime(){}
public void setStart(Date start){
this.start=start;
}
public void counttime(Date end){
this.end=end;
long howmuch=this.end.getTime()-start.getTime();
h=(int)(howmuch/1000/60/60);
howmuch=howmuch-h*60*60*1000;
m=(int)(howmuch/1000/60);
howmuch=howmuch-m*60*1000;
s=(int)(howmuch/1000);
}
public String getTimes(){
String times=this.h+"小时"+this.m+"分"+this.s+"秒";
return times;
}
public String getStart(){
return format.format(start);
}
public String getEnd(){
return format.format(end);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -