Hi all, as far as i know, date has its converter inside struts2 distribution, so one shoul do nothing to make it work.
Best greetings, Pawel Wielgus. 2009/4/30, Matt Jiang <matt.ji...@gmail.com>: > Hi > > It is nothing about date picker tag. You can have a Converter to convert > String to Date and vice versa. > Below is my implementation for your reference: > (For DateUtil, please replace with yours) > > public class DateConverter extends StrutsTypeConverter { > > private static final String PATTERN = DateUtil.PATTERN_YYYY_MM_DD; > > @Override > /** > * Converts one or more String values to the specified class. > * > * @param context the action context > * @param values the String values to be converted, such as those > submitted from an HTML form > * @param toClass the class to convert to > * @return the converted object > */ > public Object convertFromString(Map context, String[] values, Class > toClass) { > > Date returnObject = null; > String value = values[0]; > if (value != null && !value.trim().equals("")) { > try { > returnObject = DateUtil.parseDate(value, PATTERN); > } catch (ParseException e) { > // Just to ignore the parse exception > } > } > return returnObject; > } > > @Override > /** > * Converts the specified object to a String. > * > * @param context the action context > * @param o the object to be converted > * @return the converted String > */ > public String convertToString(Map context, Object o) { > > Date date = (Date) o; > String formatedDate = DateUtil.dateFormater(date, PATTERN); > return formatedDate; > } > } > > > > On Thu, Apr 30, 2009 at 1:19 AM, Richard Sayre > <richardsa...@gmail.com>wrote: > >> I have an Action with a date attribute >> >> private Date myDate; >> >> public void setMyDate(Date myDate) { >> this.myDate = myDate; >> } >> >> I have a form that has a date picker (not the struts 2 date picker) >> that populates a text field. When I submitt the form to my action the >> property does not get set because Struts 2 is looking for >> setMyDate(String myDate). >> >> How do I tell Struts that the field is a Date? >> >> >> Thank you, >> >> Rich >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org