@@ -151,15 +151,16 @@ public static JavaScalars register(Class<?> key, GraphQLScalarType value) {
151
151
}
152
152
153
153
public static class GraphQLLocalDateTimeCoercing implements Coercing <Object , Object > {
154
+ private static DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd'T'HH:mm:ss" );
154
155
155
156
@ Override
156
157
public Object serialize (Object input ) {
157
158
if (input instanceof String ) {
158
159
return parseStringToLocalDateTime ((String ) input );
159
160
} else if (input instanceof LocalDateTime ) {
160
- return input ;
161
+ return (( LocalDateTime ) input ). format ( formatter ) ;
161
162
}else if (input instanceof LocalDate ) {
162
- return input ;
163
+ return (( LocalDate ) input ). format ( formatter ) ;
163
164
} else if (input instanceof Long ) {
164
165
return parseLongToLocalDateTime ((Long ) input );
165
166
} else if (input instanceof Integer ) {
@@ -200,12 +201,14 @@ private LocalDateTime parseStringToLocalDateTime(String input) {
200
201
201
202
public static class GraphQLLocalDateCoercing implements Coercing <Object , Object > {
202
203
204
+ private static DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd" );
205
+
203
206
@ Override
204
207
public Object serialize (Object input ) {
205
208
if (input instanceof String ) {
206
209
return parseStringToLocalDate ((String ) input );
207
210
} else if (input instanceof LocalDate ) {
208
- return input ;
211
+ return (( LocalDate ) input ). format ( formatter ) ;
209
212
} else if (input instanceof Long ) {
210
213
return parseLongToLocalDate ((Long ) input );
211
214
} else if (input instanceof Integer ) {
@@ -314,7 +317,7 @@ public Object serialize(Object input) {
314
317
if (input instanceof String ) {
315
318
return parseStringToDate ((String ) input );
316
319
} else if (input instanceof Date ) {
317
- return input ;
320
+ return new SimpleDateFormat ( dateFormatString ). format ( input ) ;
318
321
} else if (input instanceof Long ) {
319
322
return new Date (((Long ) input ).longValue ());
320
323
} else if (input instanceof Integer ) {
@@ -358,7 +361,9 @@ public Object serialize(Object input) {
358
361
if (input instanceof String ) {
359
362
return parseStringToInstant ((String ) input );
360
363
} else if (input instanceof Instant ) {
361
- return input ;
364
+ return input .toString ();
365
+ } else if (input instanceof Long ) {
366
+ return Instant .ofEpochMilli ((Long ) input );
362
367
}
363
368
return null ;
364
369
}
0 commit comments