You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ch...@t-systems.com on 2013/06/13 11:28:59 UTC

DateConverter getFormat

Hello,

In my application the server's timezone could be different to the client's timezone. So in my BasicPage I get the client's timezone with this call: ((WebClientInfo)getSession().getClientInfo()).getProperties().getTimeZone();

So every DateTextField and DateLabel should convert the date between client and server right? Now I want to add a DateLabel. The constructor wants a Converter so I add this:

DateLabel datelabel = new DateLabel("date",new PropertyModel<Date>(model,"eventTimestamp"),new DateConverter(true) {
                @Override
                public String getDatePattern(Locale locale) {
                    return "dd.MM.yyyy HH:mm:ss";
                }

                @Override
                protected DateTimeFormatter getFormat(Locale locale) {
                    return null;  //To change body of implemented methods use File | Settings | File Templates.
                }

            });
I don't now how to override the getFormat-method. Can you help me please?

Thanks

Mit freundlichen Grüßen
Christoph Manig



Re: DateConverter getFormat

Posted by Martin Grigorov <mg...@apache.org>.
DateLabel has various static #forXyz() factory methods.
Use any of them.


On Thu, Jun 13, 2013 at 12:58 PM, <Ch...@t-systems.com> wrote:

> Hello,
>
> thank you for your help. But this wouldn#t work because the return type of
> getFormat in my example is DateTimeFormatter from joda. Is there another
> example? Why I have to override this method?
>
>
> Mit freundlichen Grüßen
> Christoph Manig
> Systems Engineer
>
> T-Systems International GmbH
> Systems Integration - SC Travel, Transport & Logistics
> Hoyerswerdaer Str. 18
> 01099 Dresden
> tel.:   +49 (0) 351 / 8152 - 188
> fax:    +49 (0) 351 / 8152 – 209
> email:  Christoph.Manig@t-systems.com
>
> -----Ursprüngliche Nachricht-----
> Von: Martin Grigorov [mailto:mgrigorov@apache.org]
> Gesendet: Donnerstag, 13. Juni 2013 11:41
> An: users@wicket.apache.org
> Betreff: Re: DateConverter getFormat
>
> Hi,
>
> Here is one example:
>
> https://github.com/apache/wicket/blob/master/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/DateTextField.java?source=cc#L128
>
>
> On Thu, Jun 13, 2013 at 12:28 PM, <Ch...@t-systems.com> wrote:
>
> > Hello,
> >
> > In my application the server's timezone could be different to the
> > client's timezone. So in my BasicPage I get the client's timezone with
> this call:
> > ((WebClientInfo)getSession().getClientInfo()).getProperties().getTimeZ
> > one();
> >
> > So every DateTextField and DateLabel should convert the date between
> > client and server right? Now I want to add a DateLabel. The
> > constructor wants a Converter so I add this:
> >
> > DateLabel datelabel = new DateLabel("date",new
> > PropertyModel<Date>(model,"eventTimestamp"),new DateConverter(true) {
> >                 @Override
> >                 public String getDatePattern(Locale locale) {
> >                     return "dd.MM.yyyy HH:mm:ss";
> >                 }
> >
> >                 @Override
> >                 protected DateTimeFormatter getFormat(Locale locale) {
> >                     return null;  //To change body of implemented
> > methods use File | Settings | File Templates.
> >                 }
> >
> >             });
> > I don't now how to override the getFormat-method. Can you help me please?
> >
> > Thanks
> >
> > Mit freundlichen Grüßen
> > Christoph Manig
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

AW: DateConverter getFormat

Posted by Ch...@t-systems.com.
Hello,

thank you for your help. But this wouldn#t work because the return type of getFormat in my example is DateTimeFormatter from joda. Is there another example? Why I have to override this method?


Mit freundlichen Grüßen
Christoph Manig
Systems Engineer

T-Systems International GmbH
Systems Integration - SC Travel, Transport & Logistics
Hoyerswerdaer Str. 18
01099 Dresden 
tel.:	+49 (0) 351 / 8152 - 188
fax:	+49 (0) 351 / 8152 – 209
email:  Christoph.Manig@t-systems.com

-----Ursprüngliche Nachricht-----
Von: Martin Grigorov [mailto:mgrigorov@apache.org] 
Gesendet: Donnerstag, 13. Juni 2013 11:41
An: users@wicket.apache.org
Betreff: Re: DateConverter getFormat

Hi,

Here is one example:
https://github.com/apache/wicket/blob/master/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/DateTextField.java?source=cc#L128


On Thu, Jun 13, 2013 at 12:28 PM, <Ch...@t-systems.com> wrote:

> Hello,
>
> In my application the server's timezone could be different to the 
> client's timezone. So in my BasicPage I get the client's timezone with this call:
> ((WebClientInfo)getSession().getClientInfo()).getProperties().getTimeZ
> one();
>
> So every DateTextField and DateLabel should convert the date between 
> client and server right? Now I want to add a DateLabel. The 
> constructor wants a Converter so I add this:
>
> DateLabel datelabel = new DateLabel("date",new 
> PropertyModel<Date>(model,"eventTimestamp"),new DateConverter(true) {
>                 @Override
>                 public String getDatePattern(Locale locale) {
>                     return "dd.MM.yyyy HH:mm:ss";
>                 }
>
>                 @Override
>                 protected DateTimeFormatter getFormat(Locale locale) {
>                     return null;  //To change body of implemented 
> methods use File | Settings | File Templates.
>                 }
>
>             });
> I don't now how to override the getFormat-method. Can you help me please?
>
> Thanks
>
> Mit freundlichen Grüßen
> Christoph Manig
>
>
>

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


Re: DateConverter getFormat

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Here is one example:
https://github.com/apache/wicket/blob/master/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/DateTextField.java?source=cc#L128


On Thu, Jun 13, 2013 at 12:28 PM, <Ch...@t-systems.com> wrote:

> Hello,
>
> In my application the server's timezone could be different to the client's
> timezone. So in my BasicPage I get the client's timezone with this call:
> ((WebClientInfo)getSession().getClientInfo()).getProperties().getTimeZone();
>
> So every DateTextField and DateLabel should convert the date between
> client and server right? Now I want to add a DateLabel. The constructor
> wants a Converter so I add this:
>
> DateLabel datelabel = new DateLabel("date",new
> PropertyModel<Date>(model,"eventTimestamp"),new DateConverter(true) {
>                 @Override
>                 public String getDatePattern(Locale locale) {
>                     return "dd.MM.yyyy HH:mm:ss";
>                 }
>
>                 @Override
>                 protected DateTimeFormatter getFormat(Locale locale) {
>                     return null;  //To change body of implemented methods
> use File | Settings | File Templates.
>                 }
>
>             });
> I don't now how to override the getFormat-method. Can you help me please?
>
> Thanks
>
> Mit freundlichen Grüßen
> Christoph Manig
>
>
>