Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Java code for current date plus 30 days

Avatar

Former Community Member

I've searched this forum and google to see if I could get something to work with negative results. I created a form on Livecycle 8.2 and I'm trying to set a due date 30 days from todays date. When the form is opened I have the current date and time, read only, displayed so I would also like the due date to automatically show. I know nothing about Java and what I've used so far I've been able to copy and paste to my form. Any help would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 7

It has been over-complicated. All you need is:

$ = Num2Date(date() + 30, "MM/DD/YYYY")

View solution in original post

10 Replies

Avatar

Level 7

You use the Date2Num and Num2Date functions to do this. You turn the first date into a number using Date2Num then add 30 to it and turn it back into a date using Num2Date.

Avatar

Former Community Member

Hmmm. I've seen these in my searching but have no idea what to do with them. Thanks.

Avatar

Level 5

Drag date field  and select layout ready event and language - formcalc and keep below script that would help you.

$.rawValue= num2date(date2num(num2date(date(), DateFmt(3)))+30)

Vjay

Avatar

Former Community Member

Thanks. It worked but what would I do to display the date as MM/DD/YYYY and make it read only?

Avatar

Former Community Member

I have the read only part worked out and have been playing with the format but can't get it to display how I want it.

Avatar

Level 5

$.rawValue= num2date(date2num(num2date(date(), "MM/DD/YYYY"))+30)

Check this it might work.

Vjay

Avatar

Former Community Member

I actually tried this earlier this morning and it returns the date "Jan 30, 1900".

Avatar

Correct answer by
Level 7

It has been over-complicated. All you need is:

$ = Num2Date(date() + 30, "MM/DD/YYYY")

Avatar

Former Community Member

Exactly what I needed and it works perfectly! Thank you soooo much!

Avatar

Level 2

I need this but in Java not FormCalc. Using the tools actionbuilder converts everything to java and nullifies FormCalc....blah