Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use current date that would be a condition to control page layout?

s June 30, 2011

We modified the blog-posts-titles.vm which in confluence-advanced-macros-x.x.x.x.jar to fulfill our needs.

One requirement is to show an icon if the blogpost's creation date + 14d <=current date.

But i cannot find out how to get current date in velocity template and use it in if-then syntax.

In http://www.java2s.com/Code/Java/Velocity/HowtouseDateinVelocity.htm<sup></sup> it seems to use "$date" can get it, but i failed.

Can you tell me how to get current date?

Thanks a lot!.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Alain Moran
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2011

To get hold of the current date in java you would create a new Date() object, unfortunatley it's not possible to construct new objects in velocity without a factory method.

If you were able to use wiki-markup and had the builder theme installed then I would suggest the following:

{code}

{builder-show:olderthan=14d}Content is more than 14 days old{builder-show}

{code}

http://www.adaptavist.com/display/Builder/builder-show+macro

s July 3, 2011

Than you for the advice, Builder theme is a great plugin.

As the velocity factory method, did you mean velocity-tools-x.x.jar? Can i just copy the jar file to \lib directory and use "$date" to get current date? But I cannot find velocity-tools-1.x.jar, I'm afraid velocity-tools-2.0.jar cannot work with Confluence 3.0.

0 votes
s July 3, 2011

Thank you for your advice.

Builder theme is a great plugin and we using it in other situation.

But in this case, it seem's can not add an icon to some blogpost titles in a list.

As the velocity factory method, did you mean velocity-tools-x.x.jar? Can i just copy the jar file to \lib directory and use "$date" to get current date? But I cannot find velocity-tools-1.x.jar, I'm afraid velocity-tools-2.0.jar cannot work with Confluence 3.0...

TAGS
AUG Leaders

Atlassian Community Events