You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Mehrle <mi...@ask.com> on 2008/06/02 23:53:56 UTC
java.util.Date model accepting Date incl. time?
I have a text field that is backed by a java.util.Date model. When
typing in a simple date (e.g. 4/1/2009) everything is fine. But when I
type in a date including a time (e.g. 5/23/09 12:00 AM) I get a
validation error:
'5/23/09 12:00 AM' is not a valid Date.
Obviously a date (unlike a Timestamp) should be able to accept a 'full'
date - how do I fix this?
Michael
RE: java.util.Date model accepting Date incl. time?
Posted by Michael Mehrle <mi...@ask.com>.
Yeah, I had a suspicion that this was related but I wasn't sure I wanted
to switch on the time format for the entire site. For instance - some
users might only type in the short date version - some others the long
one. I'm not sure how to address this.
Michael
-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
Sent: Monday, June 02, 2008 3:20 PM
To: users@wicket.apache.org
Subject: Re: java.util.Date model accepting Date incl. time?
It looks like because the DateConverter code uses
DateFormat.getDateInstance(DateFormat.SHORT, locale);, if you dig into
this
method, it uses time style "FULL", which is documented like this:
"3:30:42pm
PST". Try using that for your date. If that works, than the problem is
just that it expects a much longer version of the time.
If that's the case, just override the converter for java.util.Date (I
know
you know how to do this ;) and you could put a new DateConverter, and
override this method to return whatever you want. For instance you
could do
DateFormat.getDateTimeInstance(foo, bar, foo, bar)
/**
* @param locale
* @return Returns the date format.
*/
public DateFormat getDateFormat(Locale locale)
{
if (locale == null)
{
locale = Locale.getDefault();
}
return DateFormat.getDateInstance(DateFormat.SHORT, locale);
}
On Mon, Jun 2, 2008 at 4:53 PM, Michael Mehrle <mi...@ask.com>
wrote:
> I have a text field that is backed by a java.util.Date model. When
> typing in a simple date (e.g. 4/1/2009) everything is fine. But when I
> type in a date including a time (e.g. 5/23/09 12:00 AM) I get a
> validation error:
>
>
>
> '5/23/09 12:00 AM' is not a valid Date.
>
>
>
> Obviously a date (unlike a Timestamp) should be able to accept a
'full'
> date - how do I fix this?
>
>
>
> Michael
>
>
--
Jeremy Thomerson
http://www.wickettraining.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: java.util.Date model accepting Date incl. time?
Posted by Michael Mehrle <mi...@ask.com>.
Actually, I just tried to enter various time formats but it refuses all
of them (with/without seconds, PM, PST, etc.). Only a pure date works
(e.g 3/3/2009).
Michael
-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
Sent: Monday, June 02, 2008 3:20 PM
To: users@wicket.apache.org
Subject: Re: java.util.Date model accepting Date incl. time?
It looks like because the DateConverter code uses
DateFormat.getDateInstance(DateFormat.SHORT, locale);, if you dig into
this
method, it uses time style "FULL", which is documented like this:
"3:30:42pm
PST". Try using that for your date. If that works, than the problem is
just that it expects a much longer version of the time.
If that's the case, just override the converter for java.util.Date (I
know
you know how to do this ;) and you could put a new DateConverter, and
override this method to return whatever you want. For instance you
could do
DateFormat.getDateTimeInstance(foo, bar, foo, bar)
/**
* @param locale
* @return Returns the date format.
*/
public DateFormat getDateFormat(Locale locale)
{
if (locale == null)
{
locale = Locale.getDefault();
}
return DateFormat.getDateInstance(DateFormat.SHORT, locale);
}
On Mon, Jun 2, 2008 at 4:53 PM, Michael Mehrle <mi...@ask.com>
wrote:
> I have a text field that is backed by a java.util.Date model. When
> typing in a simple date (e.g. 4/1/2009) everything is fine. But when I
> type in a date including a time (e.g. 5/23/09 12:00 AM) I get a
> validation error:
>
>
>
> '5/23/09 12:00 AM' is not a valid Date.
>
>
>
> Obviously a date (unlike a Timestamp) should be able to accept a
'full'
> date - how do I fix this?
>
>
>
> Michael
>
>
--
Jeremy Thomerson
http://www.wickettraining.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: java.util.Date model accepting Date incl. time?
Posted by Michael Mehrle <mi...@ask.com>.
I'm actually now thinking that is merely a DateValidator.range problem.
If there is a time I don't mind it being shown - it's the
DateValidator.range that won't accept it.
The other solution would be to remove the time from the model via the
converter below. However, I have not seen a way to do this - it seems
that one needs to provide a time format and that's it. How would I
ignore the time altogether?
Hope this all makes sense...
Michael
-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com]
Sent: Monday, June 02, 2008 3:20 PM
To: users@wicket.apache.org
Subject: Re: java.util.Date model accepting Date incl. time?
It looks like because the DateConverter code uses
DateFormat.getDateInstance(DateFormat.SHORT, locale);, if you dig into
this
method, it uses time style "FULL", which is documented like this:
"3:30:42pm
PST". Try using that for your date. If that works, than the problem is
just that it expects a much longer version of the time.
If that's the case, just override the converter for java.util.Date (I
know
you know how to do this ;) and you could put a new DateConverter, and
override this method to return whatever you want. For instance you
could do
DateFormat.getDateTimeInstance(foo, bar, foo, bar)
/**
* @param locale
* @return Returns the date format.
*/
public DateFormat getDateFormat(Locale locale)
{
if (locale == null)
{
locale = Locale.getDefault();
}
return DateFormat.getDateInstance(DateFormat.SHORT, locale);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: java.util.Date model accepting Date incl. time?
Posted by Jeremy Thomerson <je...@wickettraining.com>.
It looks like because the DateConverter code uses
DateFormat.getDateInstance(DateFormat.SHORT, locale);, if you dig into this
method, it uses time style "FULL", which is documented like this: "3:30:42pm
PST". Try using that for your date. If that works, than the problem is
just that it expects a much longer version of the time.
If that's the case, just override the converter for java.util.Date (I know
you know how to do this ;) and you could put a new DateConverter, and
override this method to return whatever you want. For instance you could do
DateFormat.getDateTimeInstance(foo, bar, foo, bar)
/**
* @param locale
* @return Returns the date format.
*/
public DateFormat getDateFormat(Locale locale)
{
if (locale == null)
{
locale = Locale.getDefault();
}
return DateFormat.getDateInstance(DateFormat.SHORT, locale);
}
On Mon, Jun 2, 2008 at 4:53 PM, Michael Mehrle <mi...@ask.com>
wrote:
> I have a text field that is backed by a java.util.Date model. When
> typing in a simple date (e.g. 4/1/2009) everything is fine. But when I
> type in a date including a time (e.g. 5/23/09 12:00 AM) I get a
> validation error:
>
>
>
> '5/23/09 12:00 AM' is not a valid Date.
>
>
>
> Obviously a date (unlike a Timestamp) should be able to accept a 'full'
> date - how do I fix this?
>
>
>
> Michael
>
>
--
Jeremy Thomerson
http://www.wickettraining.com