public class datelabel extends webcomponent {
private string pattern;
public datelabel(string id, imodel<date> date, string pattern) {
super(id, date);
this.pattern=pattern;
}
protected void onComponentTagBody(markupstream s, componenttag t) {
replacecomponenttagbody(s,t, new
simpledateformat(pattern).format((date)getmodelobject());
}
}
-igor
On Thu, Nov 27, 2008 at 12: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: [email protected]
>> 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.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]