@Override public Date getAsDate(final String fieldName, final String format) { return DataTypeUtils.toDate(getValue(fieldName), () -> DataTypeUtils.getDateFormat(format), fieldName); }
@Override public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { final java.text.DateFormat dateFormat = getDateFormat(this.dateFormat, context); if (dateFormat == null) { return fv; } if (!(fv.getValue() instanceof Date) && !(fv.getValue() instanceof Number)) { return fv; } final Date dateValue = DataTypeUtils.toDate(fv.getValue(), null, fv.getField().getFieldName()); final String formatted = dateFormat.format(dateValue); return new StandardFieldValue(formatted, fv.getField(), fv.getParent().orElse(null)); }); }
@Override public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { if (!(fv.getValue() instanceof String)) { return fv; } final java.text.DateFormat dateFormat = getDateFormat(this.dateFormat, context); final Date dateValue; try { dateValue = DataTypeUtils.toDate(fv.getValue(), () -> dateFormat, fv.getField().getFieldName()); } catch (final Exception e) { return fv; } if (dateValue == null) { return fv; } return new StandardFieldValue(dateValue, fv.getField(), fv.getParent().orElse(null)); }); }
final Date date = DataTypeUtils.toDate(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName); final Duration duration = Duration.between(new Date(0L).toInstant(), new Date(date.getTime()).toInstant()); final long days = duration.toDays();
return toCharacter(value, fieldName); case DATE: return toDate(value, dateFormat, fieldName); case DOUBLE: return toDouble(value, fieldName);
@Override public Date getAsDate(final String fieldName, final String format) { return DataTypeUtils.toDate(getValue(fieldName), () -> DataTypeUtils.getDateFormat(format), fieldName); }
@Override public Stream<FieldValue> evaluate(final RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { final java.text.DateFormat dateFormat = getDateFormat(this.dateFormat, context); if (dateFormat == null) { return fv; } if (!(fv.getValue() instanceof Date) && !(fv.getValue() instanceof Number)) { return fv; } final Date dateValue = DataTypeUtils.toDate(fv.getValue(), null, fv.getField().getFieldName()); final String formatted = dateFormat.format(dateValue); return new StandardFieldValue(formatted, fv.getField(), fv.getParent().orElse(null)); }); }
@Override public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) { final Stream<FieldValue> fieldValues = recordPath.evaluate(context); return fieldValues.filter(fv -> fv.getValue() != null) .map(fv -> { if (!(fv.getValue() instanceof String)) { return fv; } final java.text.DateFormat dateFormat = getDateFormat(this.dateFormat, context); final Date dateValue; try { dateValue = DataTypeUtils.toDate(fv.getValue(), () -> dateFormat, fv.getField().getFieldName()); } catch (final Exception e) { return fv; } if (dateValue == null) { return fv; } return new StandardFieldValue(dateValue, fv.getField(), fv.getParent().orElse(null)); }); }
final Date date = DataTypeUtils.toDate(rawValue, () -> DataTypeUtils.getDateFormat(format), fieldName); final Duration duration = Duration.between(new Date(0L).toInstant(), new Date(date.getTime()).toInstant()); final long days = duration.toDays();
return toCharacter(value, fieldName); case DATE: return toDate(value, dateFormat, fieldName); case DOUBLE: return toDouble(value, fieldName);