Re: How to just show the Year

Steven Scott <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thanks, that worked to correct it by using the substring.  I have also
logged a bug with NetBeans to see if they will adjust the internal object.

On Tue, Aug 24, 2010 at 5:40 PM, Daniel Dekany <[email protected]> wrote:

> Tuesday, August 24, 2010, 6:58:34 PM, Steven Scott wrote:
>
> > Error Message:
> >
> > Expected method. date?string evaluated instead to
> > freemarker.template.SimpleScalar on line 8, column 16 in
> > Templates/Scripting/EmptyPHP.php.
>
> The problem is most certainly that that the value of the "date"
> variable is not a java.util.Date (or a TemplateDateModel), but a
> string. That's the mistake of NetBeans... they should use a
> java.util.Date for a date, not a java.lang.String. Anyway, since it's
> a string, you can get a sub-string of it to extract the year, like
> ${date[0..3]}. (Or, you can cast it to date and then back to string
> with ${date?date('someFormatPattern')?string('yyyy')} where
> someFormatPattern is whatever format NetBean uses for that variable.)
>
> > On Tue, Aug 24, 2010 at 12:49 PM, Daniel Dekany <[email protected]>
> wrote:
> >
> > Tuesday, August 24, 2010, 6:23:17 PM, Steven Scott wrote:
> >
> >> I am trying to create a PHP template in NetBeans 6.9.1, and I want
> >> to include a Copyright: 2010 (or the current year).  I have the
> >> ${date} but I can not get just the year.  This is what I have:
> >>
> >> Copyright ${date?string("yyyy")}
> >>
> >> I have also tried the
> >>
> >> <#setting short="yyyy">
> >> Copyright ${date?string.short}
> >>
> >> without any luck as well.  Any help would be appreciated.
> >
> > What's the error message? This should work as far as NetBeans put a
> > variable called "date" into the data-model (with other words, into the
> > template context) which is a java.util.Date.
> >
> > --
> > Best regards,
> >  Daniel Dekany
> >
> >
> >
> ------------------------------------------------------------------------------
> > Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
> > Be part of this innovative community and reach millions of netbook users
> > worldwide. Take advantage of special opportunities to increase revenue
> and
> > speed time-to-market. Join now, and jumpstart your future.
> > http://p.sf.net/sfu/intel-atom-d2d
> > _______________________________________________
> > FreeMarker-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/freemarker-user
> >
> >
>
> --
> Best regards,
>  Daniel Dekany
>
>

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.