-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor/66 utc migration #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4532739
fix(application.yml): Update MySQL timezone to UTC for consistency
zzmnxn 0ed2a52
fix(deploy): Update MySQL timezone to UTC
zzmnxn 3f30d8e
fix: Update date handling to use UTC
zzmnxn af0a519
refactor(test): Remove dateTime field from diary requests and update β¦
zzmnxn cb90de4
refactor(DTO): Change to OffsetDateTime for UTC handling
zzmnxn 228c354
refactor(board): Update date fields to OffsetDateTime UTC handling anβ¦
zzmnxn 241e284
feat(JacksonConfig): Add custom Jackson configuration for UTC OffsetDβ¦
zzmnxn a91684f
Merge branch 'dev' of https://github.com/VoyaMeStudio/Me-mory_backendβ¦
zzmnxn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package zim.tave.memory.config; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.core.JsonGenerator; | ||
| import com.fasterxml.jackson.core.JsonParser; | ||
| import com.fasterxml.jackson.databind.DeserializationContext; | ||
| import com.fasterxml.jackson.databind.JsonDeserializer; | ||
| import com.fasterxml.jackson.databind.JsonSerializer; | ||
| import com.fasterxml.jackson.databind.SerializerProvider; | ||
| import com.fasterxml.jackson.databind.SerializationFeature; | ||
| import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
| import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| import java.io.IOException; | ||
| import java.time.OffsetDateTime; | ||
| import java.time.ZoneOffset; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.TimeZone; | ||
|
|
||
| @Configuration | ||
| public class JacksonConfig { | ||
|
|
||
| private static final DateTimeFormatter OFFSET_DATE_TIME_FORMATTER = | ||
| DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); | ||
|
|
||
| @Bean | ||
| public Jackson2ObjectMapperBuilderCustomizer utcOffsetDateTimeCustomizer() { | ||
| return builder -> { | ||
| // Ensure UTC baseline | ||
| builder.timeZone(TimeZone.getTimeZone("UTC")); | ||
| builder.serializationInclusion(JsonInclude.Include.NON_NULL); | ||
| builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | ||
|
|
||
| // Force OffsetDateTime format globally (UTC -> "Z") | ||
| JavaTimeModule javaTimeModule = new JavaTimeModule(); | ||
| javaTimeModule.addSerializer(OffsetDateTime.class, new JsonSerializer<>() { | ||
| @Override | ||
| public void serialize(OffsetDateTime value, JsonGenerator gen, SerializerProvider serializers) | ||
| throws IOException { | ||
| if (value == null) { | ||
| gen.writeNull(); | ||
| return; | ||
| } | ||
| gen.writeString(value.format(OFFSET_DATE_TIME_FORMATTER)); | ||
| } | ||
| }); | ||
| javaTimeModule.addDeserializer(OffsetDateTime.class, new JsonDeserializer<>() { | ||
| @Override | ||
| public OffsetDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
| String raw = p.getValueAsString(); | ||
| if (raw == null || raw.isBlank()) { | ||
| return null; | ||
| } | ||
| return OffsetDateTime.parse(raw, OFFSET_DATE_TIME_FORMATTER); | ||
| } | ||
| }); | ||
|
|
||
| builder.modules(javaTimeModule); | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Helper for normalizing an OffsetDateTime to UTC when needed. | ||
| * (Not wired automatically; kept for consistency utilities if required.) | ||
| */ | ||
| public static OffsetDateTime normalizeToUtc(OffsetDateTime value) { | ||
| return value == null ? null : value.withOffsetSameInstant(ZoneOffset.UTC); | ||
| } | ||
| } | ||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OffsetDateTimeμ μ¬μ©νλ λλ©μΈμ 곡ν΅μ μΌλ‘ μ μ©λλ 리뷰μ λλ€.
MySQLμ DATETIME / TIMESTAMPλ offset μ 보λ₯Ό μ μ₯νμ§ μμμ λ²μ μ λ°λΌ
λ±μ λ¬Έμ κ° λ°μν μ μλ€κ³ ν©λλ€.
μ½νμΌλΏμ΄ μλμ κ°μ΄ μ μν΄μ£Όμλλ° OffsetDateTimeAttributeConverter νμΌ μΆκ°λ₯Ό κ³ λ €ν΄λ³΄λ κ²λ μ’μ κ² κ°μμ!
κΆμ₯ μμ (κ°μ₯ μμ ν λ°©λ²)
π JPA AttributeConverter μΆκ° (DB λ³κ²½ μμ΄ ν΄κ²°)
μ νμΌ μΆκ°
src/main/java/zim/tave/memory/config/OffsetDateTimeAttributeConverter.java