diff --git a/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java b/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
index e1023397d..0ff575c7d 100644
--- a/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
+++ b/jsonschema2pojo-ant/src/main/java/org/jsonschema2pojo/ant/Jsonschema2PojoTask.java
@@ -138,16 +138,20 @@ public class Jsonschema2PojoTask extends Task implements GenerationConfig {
private boolean includeDynamicAccessors = false;
- private String dateTimeType = null;
+ private String dateTimeType;
- private String timeType = null;
+ private String timeType;
- private String dateType = null;
+ private String dateType;
private boolean formatDateTimes = false;
private boolean formatDates = false;
+ private String customDatePattern;
+
+ private String customDateTimePattern;
+
private String refFragmentPathDelimiters = "#/.";
/**
@@ -710,6 +714,30 @@ public void setFormatDates(boolean formatDates) {
this.formatDates = formatDates;
}
+ /**
+ * Sets the 'customDatePattern' property of this class
+ *
+ * @param customDatePattern
+ * A custom pattern to use when formatting date fields during
+ * serialization. Requires support from your JSON binding
+ * library.
+ */
+ public void setCustomDatePattern(String customDatePattern) {
+ this.customDatePattern = customDatePattern;
+ }
+
+ /**
+ * Sets the 'customDateTimePattern' property of this class
+ *
+ * @param customDatePattern
+ * A custom pattern to use when formatting date-time fields during
+ * serialization. Requires support from your JSON binding
+ * library.
+ */
+ public void setCustomDateTimePattern(String customDateTimePattern) {
+ this.customDateTimePattern = customDateTimePattern;
+ }
+
/**
* Sets the 'refFragmentPathDelimiters' property of this class
*
@@ -968,6 +996,16 @@ public boolean isFormatDates() {
return formatDates;
}
+ @Override
+ public String getCustomDatePattern() {
+ return customDatePattern;
+ }
+
+ @Override
+ public String getCustomDateTimePattern() {
+ return customDateTimePattern;
+ }
+
@Override
public String getRefFragmentPathDelimiters() {
return refFragmentPathDelimiters;
diff --git a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
index afe43cc7f..013bbc946 100644
--- a/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
+++ b/jsonschema2pojo-ant/src/site/Jsonschema2PojoTask.html
@@ -402,19 +402,28 @@
refFragmentPathDelimiters |
A string containing any characters that should act as path delimiters when resolving $ref
diff --git a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
index fe931eec5..5296f51be 100644
--- a/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
+++ b/jsonschema2pojo-cli/src/main/java/org/jsonschema2pojo/cli/Arguments.java
@@ -125,13 +125,13 @@ public class Arguments implements GenerationConfig {
private boolean useJodaLocalTimes = false;
@Parameter(names = { "-dtt", "--datetime-class" }, description = "Specify datetime class")
- private String dateTimeType = null;
+ private String dateTimeType;
@Parameter(names = { "-tt", "--time-class" }, description = "Specify time class")
- private String timeType = null;
+ private String timeType;
@Parameter(names = { "-dt", "--date-class" }, description = "Specify date class")
- private String dateType = null;
+ private String dateType;
@Parameter(names = { "-c3", "--commons-lang3" }, description = "Whether to use commons-lang 3.x imports instead of commons-lang 2.x imports when adding equals, hashCode and toString methods.")
private boolean useCommonsLang3 = false;
@@ -166,12 +166,18 @@ public class Arguments implements GenerationConfig {
@Parameter(names = { "-ida", "--include-dynamic-accessors" }, description = "Include dynamic getter, setter, and builder support on generated types.")
private boolean includeDynamicAccessors = false;
- @Parameter(names = { "-fd", "--format-dates" }, description = "Whether the fields of type `date` have the `@JsonFormat` annotation with pattern set to the default value of `yyyy-MM-dd`")
+ @Parameter(names = { "-fd", "--format-dates" }, description = "Whether the fields of type `date` are formatted during serialization with a default pattern of `yyyy-MM-dd`")
private boolean formatDates = false;
- @Parameter(names = { "-fdt", "--format-date-times" }, description = "Whether the fields of type `date-time` have the `@JsonFormat` annotation with pattern set to the default value of `yyyy-MM-dd'T'HH:mm:ss.SSS` and timezone set to default value of `UTC`")
+ @Parameter(names = { "-fdt", "--format-date-times" }, description = "Whether the fields of type `date-time` are formatted during serialization with a default pattern of `yyyy-MM-dd'T'HH:mm:ss.SSSZ` and timezone set to default value of `UTC`")
private boolean formatDateTimes = false;
+ @Parameter(names = { "-dp", "--date-pattern" }, description = "A custom pattern to use when formatting date fields during serialization")
+ private String customDatePattern;
+
+ @Parameter(names = { "-dtp", "--date-time-pattern" }, description = "A custom pattern to use when formatting date-time fields during serialization")
+ private String customDateTimePattern;
+
@Parameter(names = {"-rpd", "--ref-fragment-path-delimiters"}, description = "A string containing any characters that should act as path delimiters when resolving $ref fragments. By default, #, / and . are used in an attempt to support JSON Pointer and JSON Path.")
private String refFragmentPathDelimiters = "#/.";
@@ -434,4 +440,14 @@ public String getRefFragmentPathDelimiters() {
return refFragmentPathDelimiters;
}
+ @Override
+ public String getCustomDatePattern() {
+ return customDatePattern;
+ }
+
+ @Override
+ public String getCustomDateTimePattern() {
+ return customDateTimePattern;
+ }
+
}
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
index 554febb55..b0177728c 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/DefaultGenerationConfig.java
@@ -352,4 +352,14 @@ public boolean isFormatDates() {
public String getRefFragmentPathDelimiters() {
return "#/.";
}
+
+ @Override
+ public String getCustomDatePattern() {
+ return null;
+ }
+
+ @Override
+ public String getCustomDateTimePattern() {
+ return null;
+ }
}
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
index 474254c59..94331564a 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/GenerationConfig.java
@@ -112,7 +112,6 @@ public interface GenerationConfig {
*/
boolean isUseDoubleNumbers();
-
/**
* Gets the 'useBigDecimals' configuration option.
*
@@ -156,8 +155,7 @@ public interface GenerationConfig {
* gson
* library)
* moshi1 (apply annotations from the
- * moshi
- * library)
+ * moshi library)
* none (apply no annotations at all)
*
* @see AnnotatorFactory
@@ -168,17 +166,17 @@ public interface GenerationConfig {
* Gets the 'inclusionLevel' option for Jackson1 and Jackson2 serializers.
*
* @return Level of inclusion to set in the generated Java types.
- *
- * Supported values
- *
- * ALWAYS
- * NON_ABSENT
- * NON_DEFAULT
- * NON_EMPTY
- * NON_NULL
- * USE_DEFAULTS
- *
- *
+ *
+ * Supported values
+ *
+ * ALWAYS
+ * NON_ABSENT
+ * NON_DEFAULT
+ * NON_EMPTY
+ * NON_NULL
+ * USE_DEFAULTS
+ *
+ *
*
* @see InclusionLevel
*/
@@ -335,7 +333,8 @@ public interface GenerationConfig {
/**
* Gets the 'fileExtensions' configuration option.
*
- * @return An array of strings that should be considered as file extensions and therefore not included in class names.
+ * @return An array of strings that should be considered as file extensions
+ * and therefore not included in class names.
*/
String[] getFileExtensions();
@@ -374,86 +373,105 @@ public interface GenerationConfig {
/**
* Gets the 'targetVersion' configuration option.
*
- * @return The target version for generated source files.
+ * @return The target version for generated source files.
*/
String getTargetVersion();
/**
* Gets the `includeDynamicAccessors` configuraiton option.
*
- * @return Whether to include dynamic getters, setters, and builders
- * or to omit these methods.
+ * @return Whether to include dynamic getters, setters, and builders or to
+ * omit these methods.
*/
boolean isIncludeDynamicAccessors();
/**
* Gets the `dateTimeType` configuration option.
- *
- * Example values:
- *
- * org.joda.time.LocalDateTime (Joda)
- * java.time.LocalDateTime (JSR310)
- * null (default behavior)
- *
+ *
+ * Example values:
+ *
+ * org.joda.time.LocalDateTime (Joda)
+ * java.time.LocalDateTime (JSR310)
+ * null (default behavior)
+ *
*
- * @return The java type to use instead of {@link java.util.Date}
- * when adding date type fields to generate Java types.
+ * @return The java type to use instead of {@link java.util.Date} when
+ * adding date type fields to generate Java types.
*/
String getDateTimeType();
/**
* Gets the `dateType` configuration option.
- *
- * Example values:
- *
- * org.joda.time.LocalDate (Joda)
- * java.time.LocalDate (JSR310)
- * null (default behavior)
- *
- *
- * @return The java type to use instead of string
- * when adding string type fields with a format of date (not
- * date-time) to generated Java types.
+ *
+ * Example values:
+ *
+ * org.joda.time.LocalDate (Joda)
+ * java.time.LocalDate (JSR310)
+ * null (default behavior)
+ *
+ *
+ * @return The java type to use instead of string when adding string type
+ * fields with a format of date (not date-time) to generated Java
+ * types.
*/
String getDateType();
/**
* Gets the `timeType` configuration option.
- *
- * Example values:
- *
- * org.joda.time.LocalTime (Joda)
- * java.time.LocalTime (JSR310)
- * null (default behavior)
- *
- *
- * @return The java type to use instead of string
- * when adding string type fields with a format of time (not
- * date-time) to generated Java types.
+ *
+ * Example values:
+ *
+ * org.joda.time.LocalTime (Joda)
+ * java.time.LocalTime (JSR310)
+ * null (default behavior)
+ *
+ *
+ * @return The java type to use instead of string when adding string type
+ * fields with a format of time (not date-time) to generated Java
+ * types.
*/
String getTimeType();
/**
* Gets the `formatDates` configuration option
*
- * @return Whether the fields of type date have the @JsonFormat annotation
- * with pattern set to the default value of yyyy-MM-dd
+ * @return Whether the fields of type date have the
+ * @JsonFormat annotation with pattern set to the
+ * default value of yyyy-MM-dd
*/
boolean isFormatDates();
/**
* Gets the `formatDateTime` configuration option
*
- * @return Whether the fields of type date-type have the @JsonFormat annotation
- * with pattern set to the default value of yyyy-MM-dd'T'HH:mm:ss.SSSZ
+ * @return Whether the fields of type date-type have the
+ * @JsonFormat annotation with pattern set to the
+ * default value of yyyy-MM-dd'T'HH:mm:ss.SSSZ
*/
boolean isFormatDateTimes();
+ /**
+ * Gets the 'customDatePattern' configuration option
+ *
+ * @return The custom format that dates will use when types are serialized.
+ * Requires support from your JSON binding library.
+ */
+ String getCustomDatePattern();
+
+ /**
+ * Gets the 'customDateTimePattern' configuration option
+ *
+ * @return The custom format that dates will use when types are serialized.
+ * Requires support from your JSON binding library.
+ */
+ String getCustomDateTimePattern();
+
/**
* Gets the `refFragmentPathDelimiters` configuration option.
*
- * @return A string containing any characters that should act as path delimiters when resolving $ref fragments.
- * By default, #, / and . are used in an attempt to support JSON Pointer and JSON Path.
+ * @return A string containing any characters that should act as path
+ * delimiters when resolving $ref fragments. By default, #, / and .
+ * are used in an attempt to support JSON Pointer and JSON Path.
*/
String getRefFragmentPathDelimiters();
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson1Annotator.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson1Annotator.java
index 2e1bce787..726569dad 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson1Annotator.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson1Annotator.java
@@ -44,7 +44,7 @@
*/
public class Jackson1Annotator extends AbstractAnnotator {
- private JsonSerialize.Inclusion inclusionLevel = JsonSerialize.Inclusion.NON_NULL;
+ private final JsonSerialize.Inclusion inclusionLevel;
public Jackson1Annotator(GenerationConfig generationConfig) {
super(generationConfig);
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson2Annotator.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson2Annotator.java
index 7af69c14b..11093d21b 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson2Annotator.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/Jackson2Annotator.java
@@ -16,10 +16,14 @@
package org.jsonschema2pojo;
+import static org.apache.commons.lang3.StringUtils.*;
+
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.jsonschema2pojo.rules.FormatRule;
+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
@@ -47,10 +51,7 @@
*/
public class Jackson2Annotator extends AbstractAnnotator {
- private static String ISO_8601_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
- private static String ISO_8601_DATE_FORMAT = "yyyy-MM-dd";
-
- private JsonInclude.Include inclusionLevel = JsonInclude.Include.NON_NULL;
+ private final JsonInclude.Include inclusionLevel;
public Jackson2Annotator(GenerationConfig generationConfig) {
super(generationConfig);
@@ -163,8 +164,10 @@ public void dateField(JFieldVar field, JsonNode node) {
pattern = node.get("customDatePattern").asText();
} else if (node.has("customPattern")) {
pattern = node.get("customPattern").asText();
+ } else if (isNotEmpty(getGenerationConfig().getCustomDatePattern())) {
+ pattern = getGenerationConfig().getCustomDatePattern();
} else if (getGenerationConfig().isFormatDates()) {
- pattern = ISO_8601_DATE_FORMAT;
+ pattern = FormatRule.ISO_8601_DATE_FORMAT;
}
if (pattern != null && !field.type().fullName().equals("java.lang.String")) {
@@ -181,8 +184,10 @@ public void dateTimeField(JFieldVar field, JsonNode node) {
pattern = node.get("customDateTimePattern").asText();
} else if (node.has("customPattern")) {
pattern = node.get("customPattern").asText();
+ } else if (isNotEmpty(getGenerationConfig().getCustomDateTimePattern())) {
+ pattern = getGenerationConfig().getCustomDateTimePattern();
} else if (getGenerationConfig().isFormatDateTimes()) {
- pattern = ISO_8601_DATETIME_FORMAT;
+ pattern = FormatRule.ISO_8601_DATETIME_FORMAT;
}
if (pattern != null && !field.type().fullName().equals("java.lang.String")) {
diff --git a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/FormatRule.java b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/FormatRule.java
index 5d8eeb6cc..2d5c0ed8b 100644
--- a/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/FormatRule.java
+++ b/jsonschema2pojo-core/src/main/java/org/jsonschema2pojo/rules/FormatRule.java
@@ -42,6 +42,9 @@
*/
public class FormatRule implements Rule {
+ public static String ISO_8601_DATE_FORMAT = "yyyy-MM-dd";
+ public static String ISO_8601_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
+
private final RuleFactory ruleFactory;
protected FormatRule(RuleFactory ruleFactory) {
diff --git a/jsonschema2pojo-gradle-plugin/README.md b/jsonschema2pojo-gradle-plugin/README.md
index 2e16e4bc3..b9b0e5082 100644
--- a/jsonschema2pojo-gradle-plugin/README.md
+++ b/jsonschema2pojo-gradle-plugin/README.md
@@ -137,10 +137,12 @@ jsonSchema2Pojo {
useJodaDates = false
// Whether to add JsonFormat annotations when using Jackson 2 that cause format "date" and "date-time"
- // fields to be formatted as yyyy-MM-dd and yyyy-MM-dd'T'HH:mm:ss.SSS respectively
+ // fields to be formatted as yyyy-MM-dd and yyyy-MM-dd'T'HH:mm:ss.SSSZ respectively. To customize these
+ // patterns, use customDatePattern and customDateTimePattern config options or add these inside a schema
+ // to affect an individual field
formatDateTimes = true
formatDates = true
-
+
// Whether to use commons-lang 3.x imports instead of commons-lang 2.x imports when adding equals,
// hashCode and toString methods.
useCommonsLang3 = false
diff --git a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
index 713c598cc..5163ae158 100644
--- a/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
+++ b/jsonschema2pojo-gradle-plugin/src/main/groovy/org/jsonschema2pojo/gradle/JsonSchemaExtension.groovy
@@ -74,6 +74,8 @@ public class JsonSchemaExtension implements GenerationConfig {
FileFilter fileFilter
boolean formatDates
boolean formatDateTimes
+ String customDatePattern
+ String customDateTimePattern
String refFragmentPathDelimiters
public JsonSchemaExtension() {
@@ -206,6 +208,8 @@ public class JsonSchemaExtension implements GenerationConfig {
|includeDynamicAccessors = ${includeDynamicAccessors}
|formatDates = ${formatDates}
|formatDateTimes = ${formatDateTimes}
+ |customDatePattern = ${customDatePattern}
+ |customDateTimePattern = ${customDateTimePattern}
|refFragmentPathDelimiters = ${refFragmentPathDelimiters}
""".stripMargin()
}
diff --git a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CustomDateTimeFormatIT.java b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CustomDateTimeFormatIT.java
index fd4f84a77..d4d3dacaf 100644
--- a/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CustomDateTimeFormatIT.java
+++ b/jsonschema2pojo-integration-tests/src/test/java/org/jsonschema2pojo/integration/CustomDateTimeFormatIT.java
@@ -37,6 +37,7 @@ public class CustomDateTimeFormatIT {
private static Class> classWhenFormatDatesTrue;
private static Class> classWhenFormatDatesFalse;
+ private static Class> classWithCustomPatterns;
@BeforeClass
public static void generateClasses() throws ClassNotFoundException, IOException {
@@ -51,10 +52,40 @@ public static void generateClasses() throws ClassNotFoundException, IOException
"formatDateTimes", Boolean.FALSE,
"formatDates", Boolean.FALSE));
+ classSchemaRule.generate("/schema/format/customDateTimeFormat.json", "com.example.config_custom", config(
+ "dateType", "java.util.Date",
+ "customDatePattern", "yyyy",
+ "customDateTimePattern", "yyyy-MM-dd HH:mm X",
+ "formatDateTimes", Boolean.TRUE,
+ "formatDates", Boolean.TRUE));
+
ClassLoader loader = classSchemaRule.compile();
classWhenFormatDatesTrue = loader.loadClass("com.example.config_true.CustomDateTimeFormat");
classWhenFormatDatesFalse = loader.loadClass("com.example.config_false.CustomDateTimeFormat");
+ classWithCustomPatterns = loader.loadClass("com.example.config_custom.CustomDateTimeFormat");
+ }
+
+ @Test
+ public void testDefaultFormattedDateWithCustomPattern() throws Exception {
+
+ final Object instance = classWithCustomPatterns.newInstance();
+ classWithCustomPatterns.getMethod("setDefaultFormatDate", Date.class).invoke(instance, new Date(999999999999L));
+
+ final String json = new ObjectMapper().writeValueAsString(instance);
+
+ assertThat(json, is("{\"defaultFormatDate\":\"2001\"}"));
+ }
+
+ @Test
+ public void testDefaultFormattedDateTimeWithCustomPattern() throws Exception {
+
+ final Object instance = classWithCustomPatterns.newInstance();
+ classWithCustomPatterns.getMethod("setDefaultFormat", Date.class).invoke(instance, new Date(999999999999L));
+
+ final String json = new ObjectMapper().writeValueAsString(instance);
+
+ assertThat(json, is("{\"defaultFormat\":\"2001-09-09 01:46 Z\"}"));
}
@Test
diff --git a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
index 2bf3c3200..ae52f95f4 100644
--- a/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
+++ b/jsonschema2pojo-maven-plugin/src/main/java/org/jsonschema2pojo/maven/Jsonschema2PojoMojo.java
@@ -569,9 +569,18 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
private MavenProject project;
/**
- * Whether the fields of type `date-time` have the `@JsonFormat` annotation
- * with pattern set to the default value of `yyyy-MM-dd'T'HH:mm:ss.SSS` and
- * timezone set to default value of `UTC`
+ * Whether the fields of type `date` are formatted during serialization with
+ * a default pattern of yyyy-MM-dd.
+ *
+ * @parameter expression="${jsonschema2pojo.formatDates}"
+ * default-value="false"
+ * @since 0.4.33
+ */
+ private boolean formatDates = false;
+
+ /**
+ * Whether the fields of type `date` are formatted during serialization with
+ * a default pattern of yyyy-MM-dd'T'HH:mm:ss.SSSZ.
*
* @parameter expression="${jsonschema2pojo.formatDateTimes}"
* default-value="false"
@@ -580,14 +589,22 @@ public class Jsonschema2PojoMojo extends AbstractMojo implements GenerationConfi
private boolean formatDateTimes = false;
/**
- * Whether the fields of type `date` have the `@JsonFormat` annotation
- * with pattern set to the default value of `yyyy-MM-dd`.
+ * A custom pattern to use when formatting date fields during serialization.
+ * Requires support from your JSON binding library.
*
- * @parameter expression="${jsonschema2pojo.formatDates}"
- * default-value="false"
+ * @parameter expression "${jsonschema2pojo.customDatePattern}"
* @since 0.4.33
*/
- private boolean formatDates = false;
+ private String customDatePattern;
+
+ /**
+ * A custom pattern to use when formatting date-time fields during
+ * serialization. Requires support from your JSON binding library.
+ *
+ * @parameter expression "${jsonschema2pojo.customDatePattern}"
+ * @since 0.4.33
+ */
+ private String customDateTimePattern;
/**
* A string containing any characters that should act as path delimiters when resolving $ref fragments.
@@ -941,6 +958,16 @@ public boolean isFormatDates() {
return formatDates;
}
+ @Override
+ public String getCustomDatePattern() {
+ return customDatePattern;
+ }
+
+ @Override
+ public String getCustomDateTimePattern() {
+ return customDateTimePattern;
+ }
+
@Override
public String getRefFragmentPathDelimiters() {
return refFragmentPathDelimiters;
|