File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 3
3
import java .time .LocalDateTime ;
4
4
import java .time .format .DateTimeFormatter ;
5
5
6
+ import org .eclipse .jdt .core .dom .ThisExpression ;
7
+
6
8
public class TimeUtil {
7
9
10
+ public long startTime ;
11
+ public long endTime ;
12
+
13
+ public TimeUtil () {
14
+ this .startTime = System .nanoTime ();
15
+ }
16
+
17
+ public void setEndTime () {
18
+ this .endTime = System .nanoTime ();
19
+ }
20
+
21
+ public int computeTimeCostInMinuts () {
22
+ return (int ) ((this .endTime - this .startTime ) / (1_000_000_000 * 60 ));
23
+ }
24
+
25
+ public int computeTimeCostInSecond () {
26
+ return (int ) ((this .endTime - this .startTime ) / 1_000_000_000 );
27
+ }
28
+
8
29
public static void printCurTime () {
9
30
DateTimeFormatter dtf = DateTimeFormatter .ofPattern ("yyyy/MM/dd HH:mm:ss" );
10
31
LocalDateTime now = LocalDateTime .now ();
@@ -20,4 +41,5 @@ public static void printCurTimewithMsg(String msg) {
20
41
public static void main (String [] args ) {
21
42
printCurTimewithMsg ("test" );
22
43
}
44
+
23
45
}
You can’t perform that action at this time.
0 commit comments