assuming your stack param is Date value this statement is causing exception
String s=((String[])value)[0];
you need to either use DateFormat.toString()
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html
OR date.toString() e.g.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html#toString()
Martin--
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed. If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy. Thank you.
----- Original Message -----
From: "××o×-× ×Y ×z×¢×T×Y" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Sunday, May 06, 2007 2:45 AM
Subject: attempting to use time Converter?
hi...
i've created a string to time Conversion:
public Object convertValue(Map ctx, Object value, Class toType) {
if(toType==String.class){
return convert((Date) value);
}
if(toType==Date.class){
String s=((String[])value)[0];
return convert(s);
}
return null;
}
protected Date convert(String v) {
final Calendar calendar=new GregorianCalendar();
if (v.indexOf(':')>0){
calendar.set(Calendar.HOUR_OF_DAY,new Integer(v.split(":")[0]));
calendar.set(Calendar.MINUTE,new Integer(v.split(":")[1]));
return calendar.getTime();
}
return null;
}
protected String convert(Date value){
final Calendar calendar=new GregorianCalendar();
calendar.setTime( value==null ? new Date(): value);
String s=calendar.get(Calendar.HOUR_OF_DAY)+
":"+calendar.get(Calendar.MINUTE);
return s;
}
i linked it a spefici field in the properties files of an action
(reportHours-conversion.properties)
the problem begins when i define properties in Date type in the action,
the convertor sends the string correctly to the Time Picker which DOESN'T
display it, if i try typeing the same time, and move to the next field the
values i clicked vanishes, BUT if i choose the same value from time
picker's drop down, it's ok... should i loose the time picker completly??
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]