Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ private LocalDate parseStringToLocalDate(String input) {
};

public static class GraphQLDateCoercing implements Coercing<Object, Object> {
final DateFormat df;


/**
* Default to pattern 'yyyy-MM-dd'
*/
public GraphQLDateCoercing() {
df = new SimpleDateFormat("yyyy-MM-dd");
}

/**
* Parse date strings according to the provided SimpleDateFormat pattern
*
* @param dateFormatString e.g. "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" for "2001-07-04T12:08:56.235-07:00"
*/
public GraphQLDateCoercing(String dateFormatString) {
df = new SimpleDateFormat(dateFormatString);
}

@Override
public Object serialize(Object input) {
Expand Down Expand Up @@ -247,7 +265,7 @@ public Object parseLiteral(Object input) {

private Date parseStringToDate(String input) {
try {
return new SimpleDateFormat("yyyy-MM-dd").parse(input);
return df.parse(input);
} catch (ParseException e) {
log.warn("Failed to parse Date from input: " + input, e);
return null;
Expand Down