Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use the date picker in a user macro?

m_haberstock November 17, 2025

I want to use the date picker macro in a user macro. The date picker should be a user macro paramter.

Does anyone have any ideas on how I can achieve this?

1 answer

0 votes
Tomislav Tobijas
Community Champion
November 17, 2025

Hi @m_haberstock ,

You could try this (but just ⚠️ note that I haven't tested this myself; I found it in docs)

Steps to Enable Date Picker as a User Macro Parameter

  1. Allow Date Handling in User Macros
    • By default, not all Java methods for date handling are available in user macros due to security restrictions.
    • You need to update your Confluence JVM options to allow the necessary Velocity context keys and date methods. This is done by editing the `setenv.sh` file in your Confluence installation:
      CATALINA_OPTS="-Dmacro.required.velocity.context.keys=action,page,<additional-keys-if-needed>,userAccessor,content \
      -Datlassian.velocity.method.allowlist.extra=\"java.util.Calendar#set(int,int,int),java.sql.Timestamp#compareTo(java.util.Date),java.util.Date#compareTo(java.util.Date)\" ${CATALINA_OPTS}"
    • Replace `<additional-keys-if-needed>` with any other keys you require.

  2. Restart Confluence
    • After updating the JVM options, restart your Confluence instance to apply the changes.

  3. Create the User Macro
    • Go to General Configuration > User Macros.
    • Create a new macro and add a parameter for the date (e.g., `dateParam`).
    • In your macro body, you can use Velocity code to handle and display the date parameter. Here’s a basic example:
      ## Macro parameter: $paramdateParam (type: date)
      #set ($calendar = $action.getDateFormatter().getCalendar().getInstance())
      #set ($userDate = $paramdateParam)
      Date selected: $action.dateFormatter.formatGivenString("yyyy-MM-dd", $userDate)
    • When you insert this macro on a page, Confluence will provide a date picker UI for the date parameter.

Few Notes

  • Always use `$action.dateFormatter` and supported methods for date formatting and comparison.
  • If you encounter issues, double-check your JVM options and ensure the correct methods are allowed.

As this probably requires some tweaking (as you can see), maybe a better place for this question would be Developer community (folk there know infrastructure and backend much better than I 😅)

Cheers,
Tobi

m_haberstock November 17, 2025

Hi Tobi,

Thank you for your prompt reply.
I believe I lack the necessary knowledge to make such extensive changes to the Confluence configuration :-(
I am still hoping to find a solution that I can implement myself using user macro code.

Cheers,
Markus

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events