This seems to have appeared in 1.3 - when I upgraded from 1.2.6 to 1.3 is
when two separate customers reported it. The DateTextField below doesn't
actually fix it, because it appears when you supply a Timestamp to a Label,
which happens commonly with any Date pulled from the database (depending on
ORM etc).
Can one of the devs explain why this change was made? It probably should be
filed as a bug, but I'd like to make sure before I file it.
For anyone who hasn't figured out a workaround yet, here is one:
Add this to your web app init method:
((ConverterLocator) getConverterLocator()).set(Timestamp.class, new
IConverter<Timestamp>() {
private static final long serialVersionUID = 1L;
public Timestamp convertToObject(String value, Locale
locale) {
if (value == null) {
return null;
}
if (locale == null) {
locale = Locale.getDefault();
}
DateFormat format =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
try {
Date date = format.parse(value);
return new Timestamp(date.getTime());
} catch (ParseException e) {
throw new ConversionException("Cannot parse '"
+ value + "' using format " + format)
.setSourceValue(value).setTargetType(
Timestamp.class).setConverter(this)
.setLocale(locale);
}
}
public String convertToString(final Timestamp value, Locale
locale) {
if (value == null) {
return null;
}
if (locale == null) {
locale = Locale.getDefault();
}
DateFormat format =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
return format.format(value);
}
});
Hope this helps.
Jeremy Thomerson
http://www.wickettraining.com
On Fri, Mar 14, 2008 at 11:33 AM, Alex Jacoby <[EMAIL PROTECTED]> wrote:
> I can't answer your question about why, but I can suggest using a
> DateTextField from wicket-datetime for more control over the formatting.
> Unfortunately, it requires adding two jars (wicket-datetime and jodatime).
>
> Alex
>
> On Mar 13, 2008, at 2:08 PM, Markus Strickler wrote:
>
> Hi-
>>
>> is there any reason why SqlTimestampConverter.convertToString() only
>> returns a
>> time? Or is this a bug?
>>
>> Thanks,
>>
>> -kusako
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>