File tree 1 file changed +19
-1
lines changed
graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,24 @@ private LocalDate parseStringToLocalDate(String input) {
214
214
};
215
215
216
216
public static class GraphQLDateCoercing implements Coercing <Object , Object > {
217
+ final DateFormat df ;
218
+
219
+
220
+ /**
221
+ * Default to pattern 'yyyy-MM-dd'
222
+ */
223
+ public GraphQLDateCoercing () {
224
+ df = new SimpleDateFormat ("yyyy-MM-dd" );
225
+ }
226
+
227
+ /**
228
+ * Parse date strings according to the provided SimpleDateFormat pattern
229
+ *
230
+ * @param dateFormatString e.g. "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" for "2001-07-04T12:08:56.235-07:00"
231
+ */
232
+ public GraphQLDateCoercing (String dateFormatString ) {
233
+ df = new SimpleDateFormat (dateFormatString );
234
+ }
217
235
218
236
@ Override
219
237
public Object serialize (Object input ) {
@@ -247,7 +265,7 @@ public Object parseLiteral(Object input) {
247
265
248
266
private Date parseStringToDate (String input ) {
249
267
try {
250
- return new SimpleDateFormat ( "yyyy-MM-dd" ) .parse (input );
268
+ return df .parse (input );
251
269
} catch (ParseException e ) {
252
270
log .warn ("Failed to parse Date from input: " + input , e );
253
271
return null ;
You can’t perform that action at this time.
0 commit comments