Skip to content

Commit bcbb878

Browse files
committed
replace use of ISO8601DateFormat and ISO8601Utils with StdDateFormat
fixes OpenAPITools#5779
1 parent 7a26ce5 commit bcbb878

File tree

19 files changed

+390
-144
lines changed

19 files changed

+390
-144
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
{{>licenseInfo}}
22
package {{invokerPackage}};
33

4-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
5-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
4+
import com.fasterxml.jackson.databind.util.StdDateFormat;
65

6+
import java.text.DateFormat;
77
import java.text.FieldPosition;
8+
import java.text.ParsePosition;
89
import java.util.Date;
10+
import java.util.TimeZone;
911

12+
public class RFC3339DateFormat extends DateFormat {
13+
private static final long serialVersionUID = 1L;
14+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1015
11-
public class RFC3339DateFormat extends ISO8601DateFormat {
16+
private final StdDateFormat fmt = new StdDateFormat()
17+
.withTimeZone(TIMEZONE_Z)
18+
.withColonInTimeZone(true);
19+
20+
@Override
21+
public Date parse(String source, ParsePosition pos) {
22+
return fmt.parse(source, pos);
23+
}
1224

13-
// Same as ISO8601DateFormat but serializing milliseconds.
1425
@Override
1526
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
16-
String value = ISO8601Utils.format(date, true);
17-
toAppendTo.append(value);
18-
return toAppendTo;
27+
return fmt.format(date, toAppendTo, fieldPosition);
1928
}
2029

30+
@Override
31+
public Object clone() {
32+
return this;
33+
}
2134
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
package {{apiPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1014
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
1818
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
23+
24+
@Override
25+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
26+
return fmt.format(date, toAppendTo, fieldPosition);
27+
}
28+
29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
1933
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
package {{invokerPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1014
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
1818
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
23+
24+
@Override
25+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
26+
return fmt.format(date, toAppendTo, fieldPosition);
27+
}
28+
29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
1933
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
package {{basePackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
914
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
1118
12-
private static final long serialVersionUID = 1L;
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
1323

14-
// Same as ISO8601DateFormat but serializing milliseconds.
1524
@Override
1625
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
17-
String value = ISO8601Utils.format(date, true);
18-
toAppendTo.append(value);
19-
return toAppendTo;
26+
return fmt.format(date, toAppendTo, fieldPosition);
2027
}
2128

29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
2233
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
package {{configPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
914
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
1118
12-
private static final long serialVersionUID = 1L;
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
1323

14-
// Same as ISO8601DateFormat but serializing milliseconds.
1524
@Override
1625
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
17-
String value = ISO8601Utils.format(date, true);
18-
toAppendTo.append(value);
19-
return toAppendTo;
26+
return fmt.format(date, toAppendTo, fieldPosition);
2027
}
2128

29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
2233
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
package {{apiPackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

9-
public class RFC3339DateFormat extends ISO8601DateFormat {
11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
1014
11-
// Same as ISO8601DateFormat but serializing milliseconds.
12-
@Override
13-
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14-
String value = ISO8601Utils.format(date, true);
15-
toAppendTo.append(value);
16-
return toAppendTo;
17-
}
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
1818
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
23+
24+
@Override
25+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
26+
return fmt.format(date, toAppendTo, fieldPosition);
27+
}
28+
29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
1933
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
package {{basePackage}};
22

3-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
4-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
3+
import com.fasterxml.jackson.databind.util.StdDateFormat;
54

5+
import java.text.DateFormat;
66
import java.text.FieldPosition;
7+
import java.text.ParsePosition;
78
import java.util.Date;
9+
import java.util.TimeZone;
810

11+
public class RFC3339DateFormat extends DateFormat {
12+
private static final long serialVersionUID = 1L;
13+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
914
10-
public class RFC3339DateFormat extends ISO8601DateFormat {
15+
private final StdDateFormat fmt = new StdDateFormat()
16+
.withTimeZone(TIMEZONE_Z)
17+
.withColonInTimeZone(true);
18+
19+
@Override
20+
public Date parse(String source, ParsePosition pos) {
21+
return fmt.parse(source, pos);
22+
}
1123

12-
// Same as ISO8601DateFormat but serializing milliseconds.
1324
@Override
1425
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
15-
String value = ISO8601Utils.format(date, true);
16-
toAppendTo.append(value);
17-
return toAppendTo;
26+
return fmt.format(date, toAppendTo, fieldPosition);
1827
}
1928

29+
@Override
30+
public Object clone() {
31+
return this;
32+
}
2033
}

samples/client/petstore/java/feign/src/main/java/org/openapitools/client/RFC3339DateFormat.java

+20-7
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,34 @@
1212

1313
package org.openapitools.client;
1414

15-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
16-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
15+
import com.fasterxml.jackson.databind.util.StdDateFormat;
1716

17+
import java.text.DateFormat;
1818
import java.text.FieldPosition;
19+
import java.text.ParsePosition;
1920
import java.util.Date;
21+
import java.util.TimeZone;
2022

23+
public class RFC3339DateFormat extends DateFormat {
24+
private static final long serialVersionUID = 1L;
25+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
2126

22-
public class RFC3339DateFormat extends ISO8601DateFormat {
27+
private final StdDateFormat fmt = new StdDateFormat()
28+
.withTimeZone(TIMEZONE_Z)
29+
.withColonInTimeZone(true);
30+
31+
@Override
32+
public Date parse(String source, ParsePosition pos) {
33+
return fmt.parse(source, pos);
34+
}
2335

24-
// Same as ISO8601DateFormat but serializing milliseconds.
2536
@Override
2637
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
27-
String value = ISO8601Utils.format(date, true);
28-
toAppendTo.append(value);
29-
return toAppendTo;
38+
return fmt.format(date, toAppendTo, fieldPosition);
3039
}
3140

41+
@Override
42+
public Object clone() {
43+
return this;
44+
}
3245
}

samples/client/petstore/java/feign10x/src/main/java/org/openapitools/client/RFC3339DateFormat.java

+20-7
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,34 @@
1212

1313
package org.openapitools.client;
1414

15-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
16-
import com.fasterxml.jackson.databind.util.ISO8601Utils;
15+
import com.fasterxml.jackson.databind.util.StdDateFormat;
1716

17+
import java.text.DateFormat;
1818
import java.text.FieldPosition;
19+
import java.text.ParsePosition;
1920
import java.util.Date;
21+
import java.util.TimeZone;
2022

23+
public class RFC3339DateFormat extends DateFormat {
24+
private static final long serialVersionUID = 1L;
25+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
2126

22-
public class RFC3339DateFormat extends ISO8601DateFormat {
27+
private final StdDateFormat fmt = new StdDateFormat()
28+
.withTimeZone(TIMEZONE_Z)
29+
.withColonInTimeZone(true);
30+
31+
@Override
32+
public Date parse(String source, ParsePosition pos) {
33+
return fmt.parse(source, pos);
34+
}
2335

24-
// Same as ISO8601DateFormat but serializing milliseconds.
2536
@Override
2637
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
27-
String value = ISO8601Utils.format(date, true);
28-
toAppendTo.append(value);
29-
return toAppendTo;
38+
return fmt.format(date, toAppendTo, fieldPosition);
3039
}
3140

41+
@Override
42+
public Object clone() {
43+
return this;
44+
}
3245
}

0 commit comments

Comments
 (0)