Skip to content

Commit

Permalink
Drop the Optional from timezone setting in Jackson
Browse files Browse the repository at this point in the history
It has a default value so no need for an Optional wrapper.
  • Loading branch information
gsmet committed Jan 21, 2025
1 parent e9d9380 commit b7b742e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void customize(ObjectMapper objectMapper) {
if (serializationInclusion != null) {
objectMapper.setSerializationInclusion(serializationInclusion);
}
ZoneId zoneId = jacksonBuildTimeConfig.timezone().orElse(null);
if ((zoneId != null) && !zoneId.getId().equals("UTC")) { // Jackson uses UTC as the default, so let's not reset it
ZoneId zoneId = jacksonBuildTimeConfig.timezone();
if (!zoneId.getId().equals("UTC")) { // Jackson uses UTC as the default, so let's not reset it
objectMapper.setTimeZone(TimeZone.getTimeZone(zoneId));
}
if (jacksonSupport.configuredNamingStrategy().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonInclude;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
Expand Down Expand Up @@ -52,10 +53,9 @@ public interface JacksonBuildTimeConfig {
/**
* If set, Jackson will default to using the specified timezone when formatting dates.
* Some examples values are "Asia/Jakarta" and "GMT+3".
* If not set, Jackson will use its own default.
*/
@WithDefault("UTC")
Optional<ZoneId> timezone();
ZoneId timezone();

/**
* Define which properties of Java Beans are to be included in serialization.
Expand Down

0 comments on commit b7b742e

Please sign in to comment.