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

Custom macro working with lastModificationDate

SaschaC Arlin March 21, 2024

Hey there!

I am working on a custom macro for Confluence. It should check whether the last modification date of the current page is older than X.

I am stuck with not being able to make sense of the format differences between $content.currentDate and $content.lastModificationDate.

## @param older:title=From Date|type=enum|enumValues=30 Tage, 90 Tage, 180 Tage, 365 Tage

#set( $currentD = $content.getCurrentDate())
#set( $currentOb = $content.currentDate)
#set( $res = $currentOb.setTime($content.currentDate.parse($currentD)))
#set( $currentDI = $currentOb.getTime())

## Gets the date of the last modification and transforms it to a timestamp
#set( $modD = $content.getLastModificationDate())
#set( $modOb = $content.lastModificationDate)
#set( $res = $modOb.setTime($content.lastModificationDate.parse($modD)))
#set( $modDI = $modOb.getTime())

<h3>Naked Dates</h3>
<p>Mod: $content.lastModificationDate<br>
Current: $content.currentDate</p>

<h3>Timestamps</h3>
<p>Mod: $modDI<br>
Current: $currentDI</p>

 The output looks like this:

Naked Dates

Mod: 2024-03-22 00:40:32.69
Current: Fri Mar 22 01:12:56 CET 2024

Timestamps

Mod: $modDI
Current: 1711066376496

BTW, I am not married to using timestamps … I was trying this, because I could not get $modOb.after(…) to work either …

I am pretty sure I am missing something very obvious :) Any ideas?

Thanks
Sascha

1 answer

0 votes
SaschaC Arlin March 22, 2024

Both getCurrentDate() and getLastModificationDate() should return a Date object … https://docs.atlassian.com/atlassian-core/4.3/xref/com/atlassian/core/bean/EntityObject.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events