Not really the best solution, but you can create a different label for different formats that you want, i.e.:
DateOnlyLabel (which overrides getConverter and always returns a converter that displays only the date) DateAndTimeLabel (etc....) ala... public class DateOnlyLabel extends Label { private static final long serialVersionUID = 1L; public DateOnlyLabel(String id, IModel<?> model) { super(id, model); } @Override public IConverter getConverter(Class<?> type) { return new DateConverter() { private static final long serialVersionUID = 1L; @Override public DateFormat getDateFormat(Locale locale) { return new SimpleDateFormat("MM/DD/yyyy"); } }; } } On Thu, Nov 27, 2008 at 2:06 PM, kan <[EMAIL PROTECTED]> wrote: > Yes, I know. But it takes Class only. And I have several different > formats (just date, date+time+tz, "human readable date" like "2 days > ago" and so on), how can I substitute a format in given piece of code > like add(new Label("someDate"))? > > 2008/11/27 Bruno Cesar Borges <[EMAIL PROTECTED]>: > > @Override > > public IConverter getConverter(Class<?> type) > > { > > return MyConverter(); > > } > > > > -----Mensagem original----- > > De: kan [mailto:[EMAIL PROTECTED] > > Enviada em: quinta-feira, 27 de novembro de 2008 14:57 > > Para: users@wicket.apache.org > > Assunto: Set format date "inline" > > > > > > I have a MyPojo with property java.util.Date someDate > > I use CompoundPropertyModel<MyPojo> > > Now I add components on my page, like add(new Label("someDate")) and > > it automagically uses IConvertor to convert from Date to string. > > But in some places of web-site I need print only "27/11/2008", in some > > places better will be "2 days ago", in some places "27/11/2008 > > 16:53:34 UTC" and so on. > > What is an elegant way to specify a format in particular piece of code? > > > > -- > > WBR, kan. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > *************************************************************************************************** > > "Atenção: Esta mensagem foi enviada para uso exclusivo do(s) > destinatários(s) acima identificado(s), > > podendo conter informações e/ou documentos confidencias/privilegiados e > seu sigilo é protegido por > > lei. Caso você tenha recebido por engano, por favor, informe o remetente > e apague-a de seu sistema. > > Notificamos que é proibido por lei a sua retenção, disseminação, > distribuição, cópia ou uso sem > > expressa autorização do remetente. Opiniões pessoais do remetente não > refletem, necessariamente, > > o ponto de vista da CETIP, o qual é divulgado somente por pessoas > autorizadas." > > > > > > "Warning: This message was sent for exclusive use of the addressees above > identified, possibly > > containing information and or privileged/confidential documents whose > content is protected by law. > > In case you have mistakenly received it, please notify the sender and > delete it from your system. > > Be noticed that the law forbids the retention, dissemination, > distribution, copy or use without > > express authorization from the sender. Personal opinions of the sender do > not necessarily reflect > > CETIP's point of view, which is only divulged by authorized personnel." > > > *************************************************************************************************** > > > > > > -- > WBR, kan. > -- Jeremy Thomerson http://www.wickettraining.com