I did a little bit of digging and it appears that the problem is in the
convertToObject() in the org.apache.wicket.datetime.DateConverter class.
Specifically, the return date.ToDate() line in the following code:
if (applyTimeZoneDifference)
{
TimeZone zone = getClientTimeZone();
...
}
else
{
try
{
DateTime date = format.parseDateTime(value);
return date.toDate();
}
}
jpalmer1026 wrote:
>
> I was thinking the same thing but, as you pointed out, I explicitly set it
> to false, so I'm not sure why it's behaving this way. I tried setting it
> to true just as an experiment but the results were the same. Has anyone
> else seen this?
>
>
> Stefan Malmesjö wrote:
>>
>> Could this have anything to do with applyTimeZoneDifference in
>> PatterDateConverter? It looks like you set it to false, so it shouldn't,
>> but still... it fits the description pretty well...
>> /Stefan
>>
>> On 2009-07-07 19:44, [email protected] wrote:
>>> I am having issues with a custom component that I created. The
>>> component's function is to ensure that the date entered adheres to the
>>> format "^(\\d{2})/(\\d{2})/(\\d{4})$" The problem, though, is when the
>>> form that contains the component is submitted, the date is converted
>>> to the previous day's date. For example, if a date of 07/07/2009 is
>>> entered, the value that gets submitted is 07/06/2009 at 19:00 CDT. My
>>> code (2 classes) is as follows:
>>>
>>> public class CustomDateTextField extends TextField {
>>>
>>> public CustomDateTextField(String id, IModel model, Class type) {
>>> super(id, model, type);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id, IModel model) {
>>> super(id, model);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id, Class type) {
>>> super(id, type);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> public CustomDateTextField(String id) {
>>> super(id);
>>> add(new EzdecDatePicker());
>>> }
>>>
>>> @Override
>>> public IConverter getConverter(Class<?> type) {
>>> return new StrictPatternDateConverter();
>>> }
>>> }
>>>
>>> public class StrictPatternDateConverter extends PatternDateConverter {
>>>
>>> public static final String REGEX_PATTERN =
>>> "^(\\d{2})/(\\d{2})/(\\d{4})$";
>>>
>>> public StrictPatternDateConverter() {
>>> super("MM/dd/yyyy", false);
>>> }
>>>
>>> @Override
>>> public Date convertToObject(String value, Locale locale) {
>>> final Pattern pattern = Pattern.compile(REGEX_PATTERN);
>>> if (StringUtils.isNotBlank(value) &&
>>> !pattern.matcher(value).matches()) {
>>> throw new ConversionException("Invalid date format");
>>> }
>>> return super.convertToObject(value, locale);
>>> }
>>> }
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Converter-Problem-tp24378227p24381041.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]