issue with dateTool
Hi , i m using velocity -7.jar and velocity-tools-generic-2.0.jar.
I m not able to render the date tool. I am trying all these in my template but not able to get the result. I have tried putting the Product_Date as string(12/12/2007) as well as new Date() . Not working by any possible combination.
$date.toDate("MM-dd-yyyy",$Product_Date);
$date.format( 'full','short', $date.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $Product_Date.getData()) )
$date.toDate("EEE, dd MMM yyyy hh:mm:ss Z", $Product_Date)
$date.format($Product_Date) -- I want format API also to work.
Please help..its urgent.. am i using wrong jars?
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 10 Feb, 2016 01:48 PM
Hi,
To confirm, are you attempting to do this within a Velocity Format? If so, the Date Tool is accessed using
$_DateTool
, not$date
.That being said, there are a few ways to format a date:
$_DateTool.format("FORMAT_STRING", $dateVariable)
directly$_DateTool.getDate($timestampVariable)
to convert the timestamp into a Date object. Then you can use$_DateTool.format
to format the resulting Date object (see above)$_DateTool.toDate("FORMAT_STRING", $stringVariable)
to convert the formatted string into a Date object. Then you can use$_DateTool.format
to format the resulting Date object (see above)For more information about formatting and available modifiers, see this page.
Please let me know if you have any questions.
Thanks!
2 Posted by rajani on 10 Feb, 2016 02:06 PM
Hi,
I have a javascript code:
var date1 = new org.apache.velocity.tools.generic.DateTool;
var date2 = new Date();
context.put("Product_Date", date2);
context.put("date", date1);
context.put("format", format1);
context.put("sorter", sort);
then i use the template.merge(). Then trying to render in the template as in the first query.
Sorter is working fine. But not the format and date.
so, i m using the $date. Will this not work.
3 Posted by rajani on 10 Feb, 2016 02:20 PM
I tried using _DateTool also.. but still its not working
4 Posted by Ryan Griffith on 10 Feb, 2016 06:10 PM
Hi,
My apologies, but I am not sure if I am following. Are you writing this code within a Velocity Format, a JavaScript file, or Java? Based on your initial comment, it appears you are working with Velocity; however, based on your latest comment it looks like you are working with Java.
If you can attach or paste your code as it stands, that may help provide some context as well.
Thanks!
Support Staff 5 Posted by Tim on 26 Feb, 2016 09:56 PM
Hi,
Just wanted to make sure you saw Ryan's comment above.
Thanks
Tim closed this discussion on 09 Mar, 2016 04:22 PM.