[Spring] Format datetime in rfc3339 (#3777)

* [spring-boot] format datetime in rfc3339

See #3727

* [spring-mvc] format datetime in rfc3339
This commit is contained in:
Christophe Bornet
2016-10-10 18:43:28 +02:00
committed by wing328
parent 2680995825
commit 6f2c139ff8
21 changed files with 171 additions and 12 deletions

View File

@@ -0,0 +1,20 @@
package io.swagger;
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
import java.text.FieldPosition;
import java.util.Date;
public class RFC3339DateFormat extends ISO8601DateFormat {
// Same as ISO8601DateFormat but serializing milliseconds.
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
String value = ISO8601Utils.format(date, true);
toAppendTo.append(value);
return toAppendTo;
}
}

View File

@@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;

View File

@@ -2,8 +2,8 @@ package io.swagger.api;
import io.swagger.model.Client;
import org.joda.time.LocalDate;
import org.joda.time.DateTime;
import java.math.BigDecimal;
import org.joda.time.DateTime;
import io.swagger.annotations.*;

View File

@@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;

View File

@@ -1,8 +1,8 @@
package io.swagger.api;
import io.swagger.model.Pet;
import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;

View File

@@ -1,3 +1,5 @@
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath=/v2
server.port=8080
server.port=8080
spring.jackson.date-format=io.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false