Search in sources :

Example 1 with FmtDate

use of org.supercsv.cellprocessor.FmtDate in project apex-malhar by apache.

the class CsvFormatter method getProcessor.

/**
 * Returns array of cellprocessors, one for each field
 */
private CellProcessor[] getProcessor(List<Field> fields) {
    CellProcessor[] processor = new CellProcessor[fields.size()];
    int fieldCount = 0;
    for (Field field : fields) {
        if (field.getType() == FieldType.DATE) {
            String format = field.getConstraints().get(DelimitedSchema.DATE_FORMAT) == null ? null : (String) field.getConstraints().get(DelimitedSchema.DATE_FORMAT);
            processor[fieldCount++] = new Optional(new FmtDate(format == null ? "dd/MM/yyyy" : format));
        } else {
            processor[fieldCount++] = new Optional();
        }
    }
    return processor;
}
Also used : Field(org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field) Optional(org.supercsv.cellprocessor.Optional) CellProcessor(org.supercsv.cellprocessor.ift.CellProcessor) FmtDate(org.supercsv.cellprocessor.FmtDate)

Aggregations

Field (org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field)1 FmtDate (org.supercsv.cellprocessor.FmtDate)1 Optional (org.supercsv.cellprocessor.Optional)1 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)1