Or you can use the built-in "text" tag for this:

 <webwork:text name="'{0,date,yyyy/mm/dd}'" value0="myDate"/>

("name" can be from a resource bundle, if you need i18n support)

--- boxed <[EMAIL PROTECTED]> wrote:
> Larsson, Jonas wrote:
> 
> >Can someone please give me a pointer to how to customize the
> formatter for
> >rendering date objects (and it's subclasses). I am trying to
> render a
> >java.sql.Timestamp property and it only shows the date (not the
> time) AND
> >the date is on the wrong locale.
> >
> >I remember seeing something about this somewhere, but I can't find
> it again.
> >
> >I'm using WW1.4 and the WW taglib BTW.
> >  
> >
> I wrote a tag for this, that simply uses the SimpleDateFormat
> class. I 
> have attached it.
> 
> Anders Hovmöller
> > /* Copyright 2003 Anders Hovmöller
>  *
>  * The person or persons who have associated their work with
>  * this document (the "Dedicator") hereby dedicate the entire
>  * copyright in the work of authorship identified below (the
>  * "Work") to the public domain.
>  *
>  * Dedicator makes this dedication for the benefit of the
>  * public at large and to the detriment of Dedicator's heirs
>  * and successors. Dedicator intends this dedication to be an
>  * overt act of relinquishment in perpetuity of all present
>  * and future rights under copyright law, whether vested or
>  * contingent, in the Work. Dedicator understands that such
>  * relinquishment of all rights includes the relinquishment of
>  * all rights to enforce (by lawsuit or otherwise) those
>  * copyrights in the Work.
>  *
>  * Dedicator recognizes that, once placed in the public
>  * domain, the Work may be freely reproduced, distributed,
>  * transmitted, used, modified, built upon, or otherwise
>  * exploited by anyone for any purpose, commercial or non-
>  * commercial, and in any way, including by methods that have
>  * not yet been invented or conceived.
>  */
> 
> /**
>  * Get a date from the ValueStack and format it in a nice way.
> Defaults to "yyyy-MM-dd" format.
>  */
> 
> package net.killingar.webwork.view.taglib;
> 
> import javax.servlet.jsp.JspException;
> import javax.servlet.jsp.JspTagException;
> import java.text.DateFormat;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> 
> public class DateTag extends webwork.view.taglib.WebWorkTagSupport
> {
>       // Attributes ----------------------------------------------------
>       protected String valueAttr;
>       protected String formatting = "yyyy-MM-dd";
>       protected DateFormat formatter = new SimpleDateFormat(formatting);
> 
>       // Public --------------------------------------------------------
>       public void setValue(String inName) { valueAttr = inName; }
>       public void setFormat(String inFormatting) { formatting =
> inFormatting; formatter = new SimpleDateFormat(formatting); }
> 
>       // BodyTag implementation ----------------------------------------
>       public int doStartTag() throws JspException
>       {
>               try
>               {
>                       Date value = (Date)findValue(valueAttr);
> 
>                       if (value != null)
>                               pageContext.getOut().write(formatter.format(value));
>               }
>               catch (Exception e)
>               {
>                       e.printStackTrace();
>                       throw new JspTagException("Could not show value " + valueAttr +
> ":" + e);
>               }
> 
>               return SKIP_BODY;
>       }
> }


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to