-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] : TimeUtil을 static하게 변경한다
- Loading branch information
Showing
17 changed files
with
48 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
package me.nalab.core.time; | ||
|
||
import java.time.Clock; | ||
import java.time.Instant; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* 저장된 시간을 일간되게 반환하는 util 입니다. | ||
*/ | ||
public interface TimeUtil { | ||
public class TimeUtil { | ||
|
||
/** | ||
* 저장된 시간을 LocalDateTime으로 반환합니다. | ||
* @return LocalDateTime | ||
*/ | ||
LocalDateTime toLocalDateTime(); | ||
private static Clock clock = null; | ||
|
||
/** | ||
* 저장된 시간을 Instant로 반환합니다. | ||
* @return Instant | ||
*/ | ||
Instant toInstant(); | ||
private TimeUtil() { | ||
throw new UnsupportedOperationException("Cannot invoke constructor \"TimeUtil()\""); | ||
} | ||
|
||
public static Instant toInstant() { | ||
var current = Instant.now(); | ||
if (clock != null) { | ||
current = Instant.now(clock); | ||
} | ||
return formatTo6Digit(current); | ||
} | ||
|
||
private static Instant formatTo6Digit(Instant instant) { | ||
var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSX") | ||
.withZone(ZoneId.of("UTC")); | ||
return Instant.parse(formatter.format(instant)); | ||
} | ||
|
||
public static void fixed(Clock clock) { | ||
TimeUtil.clock = clock; | ||
} | ||
} |
49 changes: 0 additions & 49 deletions
49
core/time/src/main/java/me/nalab/core/time/request/RequestTimeUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
module luffy.core.time.main { | ||
|
||
requires spring.context; | ||
requires spring.beans; | ||
|
||
exports me.nalab.core.time; | ||
exports me.nalab.core.time.request; | ||
|
||
} |
44 changes: 0 additions & 44 deletions
44
core/time/src/test/java/me/nalab/core/time/RequestTimeUtilTest.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
core/time/src/test/java/me/nalab/core/time/TestController.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
survey/survey-jpa-adaptor/src/test/java/me/nalab/survey/jpa/adaptor/TestTimeUtil.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.