Skip to content

Commit 0879675

Browse files
committed
Added SimpleCheckpoint utility
1 parent 0b0d63a commit 0879675

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- SimpleCheckpoint utility
13+
1014
## [8.6.0] - 2024-05-09
1115

1216
### Added
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.fugerit.java.core.util.checkpoint;
2+
3+
import lombok.Getter;
4+
import lombok.extern.slf4j.Slf4j;
5+
6+
@Slf4j
7+
public class SimpleCheckpoint {
8+
9+
@Getter
10+
private long baseTime;
11+
12+
public SimpleCheckpoint() {
13+
this( System.currentTimeMillis() );
14+
}
15+
16+
public SimpleCheckpoint(long baseTime) {
17+
this.baseTime = baseTime;
18+
}
19+
20+
public long getDiffMillis() {
21+
return System.currentTimeMillis() - this.getBaseTime();
22+
}
23+
24+
public String getFormatTimeDiffMillis() {
25+
return CheckpointUtils.formatTimeDiffMillis( this.getBaseTime(), System.currentTimeMillis() );
26+
}
27+
28+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package test.org.fugerit.java.core.util.checkpoint;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.fugerit.java.core.util.checkpoint.SimpleCheckpoint;
5+
import org.junit.Test;
6+
7+
@Slf4j
8+
public class TestSimpleCheckpoint {
9+
10+
@Test
11+
public void testCheckpoint() {
12+
SimpleCheckpoint checkpoint = new SimpleCheckpoint();
13+
log.info( "testCheckpoint 1 {}ms", checkpoint.getDiffMillis() );
14+
log.info( "testCheckpoint 2 {}ms", checkpoint.getFormatTimeDiffMillis() );
15+
}
16+
17+
}

0 commit comments

Comments
 (0)