Skip to content

Commit

Permalink
refactor: 6digit formatter 를 매번생성하지 않도록 수정한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Mar 12, 2024
1 parent bcc6961 commit 55478a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/kotlin/me/nalab/api/core/TimeUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import java.time.format.DateTimeFormatter

object TimeUtil {

private val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSX")
.withZone(ZoneId.of("UTC"))

private var clock: Clock? = null

fun toInstant(): Instant {
Expand All @@ -18,11 +21,7 @@ object TimeUtil {
return formatTo6Digit(current)
}

private fun formatTo6Digit(instant: Instant): Instant {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSX")
.withZone(ZoneId.of("UTC"))
return Instant.parse(formatter.format(instant))
}
private fun formatTo6Digit(instant: Instant): Instant = Instant.parse(formatter.format(instant))

fun fixed(clock: Clock) {
this.clock = clock
Expand Down

0 comments on commit 55478a4

Please sign in to comment.