Skip to content

Commit

Permalink
feat: LocalDateTime seconds 절삭(#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Aug 8, 2024
1 parent 6444839 commit b14d165
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/play/pluv/PluvApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
@EnableJpaAuditing(dateTimeProviderRef = "localDateTimeProvider")
@ConfigurationPropertiesScan
public class PluvApplication {

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/play/pluv/base/LocalDateTimeProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package play.pluv.base;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAccessor;
import java.util.Optional;
import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.stereotype.Component;

@Component
public class LocalDateTimeProvider implements DateTimeProvider {

@Override
public Optional<TemporalAccessor> getNow() {
return Optional.of(LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS));
}

}

0 comments on commit b14d165

Please sign in to comment.