Rahul Jain
Rahul Jain

Reputation: 719

Date pattern issue while parsing data with Bindy

I am reading a date value from the CSV file and the value is '21/08/2009'. Bindy is giving me a error while parsing this data as follows:

org.apache.camel.dataformat.bindy.format.FormatException: Date provided does not fit the pattern defined.

I have written the following code .

package com.project1.projectdomain;

import java.lang.String;
import java.util.Date;


import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
import org.apache.camel.dataformat.bindy.annotation.DataField;

import com.project.Identifiable;

@Entity
@CsvRecord(separator = ",")
public class Trade implements Identifiable<String> {
     Classname classobject;

    @Id
    @DataField(pos = 1)
    private String id;

    @DataField(pos=2)
    private String code;

    @Temporal(TemporalType.DATE)
    @DataField(pos=3)
    private Date date1;

    @Temporal(TemporalType.DATE)
@DataField(pos=4)
    private Date date2;

I use maven for building the project ,jpa 3.0 and apache camel.

Upvotes: 0

Views: 2234

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55750

There is a pattern attribute you need to set on @DataField and specify the Date pattern you use according to DateFormat:

@DataField(pos=4, pattern="dd/MM/yyyy")

Upvotes: 1

Related Questions