File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema Expand file tree Collapse file tree 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) {
214214 };
215215
216216 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+ }
217235
218236 @ Override
219237 public Object serialize (Object input ) {
@@ -247,7 +265,7 @@ public Object parseLiteral(Object input) {
247265
248266 private Date parseStringToDate (String input ) {
249267 try {
250- return new SimpleDateFormat ( "yyyy-MM-dd" ) .parse (input );
268+ return df .parse (input );
251269 } catch (ParseException e ) {
252270 log .warn ("Failed to parse Date from input: " + input , e );
253271 return null ;
You can’t perform that action at this time.
0 commit comments