BeanUtils.copyProperties Problem in Sturs

hi frineds,

i am getting problem in formbean to valuobject.

empForm(formbean) in String joinDate and empVO(value object) in java.sql.Date joinDate.

when i am using BeanUtil.copyPropeerties method that time i am getting error. Convert problem in date.

so any body know about that then please reply me.

Thank you.

[348 byte] By [Jayesh_Java_J2EEa] at [2007-11-27 8:52:48]
# 1

Well how do you expect the BeanUtil to know which dateformat to use to convert from Date -> String and back?

Heres a workaround for it - have two properties on your ActionForm representing the date. One as a String and one as java.sql.Date (you need to give them different names of course) but you do the conversion from String to Date in your ActionForm.

eg

public class MyActionForm{

Date joinDate;

public Date getJoinDate(){

return joinDate;

}

public void setJoinDate(Date joinDate){

this.joinDate = joinDate;

}

public String getJoinDateString(){

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

return sdf.format(joinDate);

}

public void setJoinDateString(String s){

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

this.joinDate = sdf.parse(s);

}

}

Your action form acts as a converter between String/Date.

evnafetsa at 2007-7-12 21:09:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...