This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 189843 - Date object in Freemarker is String and not a Date object
Summary: Date object in Freemarker is String and not a Date object
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 6.x
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2010-08-25 13:30 UTC by Chowarmaan
Modified: 2011-11-16 16:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Introducing "dateTime" variable of type java.util.Date (2.57 KB, patch)
2010-09-07 12:13 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chowarmaan 2010-08-25 13:30:39 UTC
Trying to create a PHP template in NetBeans 6.9.1 for a Copyright of the current year using 

Copyright ${date?string("yyyy")}

or 
<#setting short="yyyy">
Copyright ${date?string.short}

Both return an error:
Expected method. date?string evaluated instead to freemarker.template.SimpleScalar 

From Daniel Dekany with FreeMarker

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.)
Comment 1 Jaroslav Tulach 2010-08-25 14:22:45 UTC
I am slightly afraid to just change the type. But I may add a "time" variable that would be of type Date.
Comment 2 Chowarmaan 2010-08-25 17:57:42 UTC
What about a new DateTime type or something, which might be a little more clear than your Time, as I believe Time should also be a Java Time object?
Comment 3 Jaroslav Tulach 2010-09-07 12:13:31 UTC
Created attachment 101912 [details]
Introducing "dateTime" variable of type java.util.Date
Comment 4 Jaroslav Tulach 2010-09-07 12:14:51 UTC
Actually both "time" and "date" variables are already defined as strings. Thus the patch introduces new "dateTime". I'll integrate tomorrow, unless there are objections.
Comment 5 Jaroslav Tulach 2010-09-08 04:39:50 UTC
core-main#70b00b618bf4
Comment 6 Quality Engineering 2010-09-09 03:06:30 UTC
Integrated into 'main-golden', will be available in build *201009090000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/70b00b618bf4
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #189843: Introducing 'dateTime' variable for all templating engines creating from DataObject templates