You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Yazeed Isaacs <Ya...@switch.tj> on 2008/11/19 09:47:16 UTC

DateTimeField - changing the format of the date

Hi

I would like to change the format of the default displayed date
"MM/dd/yy" to "dd/MM/yyyy" when using the DateTimeField.

I cannot find any resource online that shows how this is implemented. Is
this even possible?

Yazeed Isaacs - Java Developer
yazeed@transactionjunction.co.za



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: DateTimeField - changing the format of the date

Posted by Matthias Keller <ma...@ergon.ch>.
Hi

I've implemented a custom DateConverter for that:
In my Application.java I've got:
protected IConverterLocator newConverterLocator () {
    ConverterLocator converterLocator = new ConverterLocator();
    converterLocator.set(Date.class, new MyDateConverter());
    return converterLocator;
}

class MyDateConverter extends DateConverter where I overrode getDateFormat:

    public DateFormat getDateFormat (Locale locale) {
        return new SimpleDateFormat("dd/MM/yyyy", locale);
    }

Then any textfield marked as Date will be converted using this date 
format. I haven't used DateTimeField itself but it should probably be 
the same or very close to it.
I'm using Wicket 1.3.5

Matt

Yazeed Isaacs wrote:
> Hi
>
> I would like to change the format of the default displayed date
> "MM/dd/yy" to "dd/MM/yyyy" when using the DateTimeField.
>
> I cannot find any resource online that shows how this is implemented. Is
> this even possible?
>
> Yazeed Isaacs - Java Developer
> yazeed@transactionjunction.co.za
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>   


-- 
matthias.keller@ergon.ch  +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n    smart people - smart software



Re: DateTimeField - changing the format of the date

Posted by Jeremy Thomerson <je...@wickettraining.com>.
See this reply from me a while back - you can use that to format the date
however you want globally within the app....

http://markmail.org/message/m5cyca4vsrrvcrid


On Wed, Nov 19, 2008 at 2:47 AM, Yazeed Isaacs <Ya...@switch.tj> wrote:

> Hi
>
> I would like to change the format of the default displayed date
> "MM/dd/yy" to "dd/MM/yyyy" when using the DateTimeField.
>
> I cannot find any resource online that shows how this is implemented. Is
> this even possible?
>
> Yazeed Isaacs - Java Developer
> yazeed@transactionjunction.co.za
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

RE: DateTimeField - changing the format of the date

Posted by Yazeed Isaacs <Ya...@switch.tj>.
Hey guys

Thanks for the help, but I found the solution. Its so easy. :D

The DateTimeField class has a method called
newDateTextField(PropertyModel model, String id). All that I did was
override this method as follows:

DateTimeField dateToField = new DateTimeField("dateToField", new
PropertyModel(this, "dateTo")) {
	@Override
	public Locale getLocale() {
		return new Locale("en");
	}

	@Override
	protected DateTextField newDateTextField(String id,PropertyModel
dateFieldModel) {
		return DateTextField.forDatePattern(id,
dateFieldModel,"dd/MM/yyyy");
	}
};


Regards,
Yazeed Isaacs


-----Original Message-----
From: Yazeed Isaacs [mailto:Yazeed@switch.tj] 
Sent: 19 November 2008 10:47 AM
To: users@wicket.apache.org
Subject: DateTimeField - changing the format of the date

Hi

I would like to change the format of the default displayed date
"MM/dd/yy" to "dd/MM/yyyy" when using the DateTimeField.

I cannot find any resource online that shows how this is implemented. Is
this even possible?

Yazeed Isaacs - Java Developer
yazeed@transactionjunction.co.za



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org