The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to reigister at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Active IQ Unified Manager Discussions

WFA - MVEL Function to get current date

CLAYTONJS

Has anybody been able to create an MVEL function to get the current date? Or is this even possible?

 

I was hoping to use this so that when I called the function it would return a date in a format i.e. ddMMMyyyy. I've been reading up and have been trying different things, but have had no luck what so ever.

 

Any help is appreciated.

 

Cheers,

Clayton

1 ACCEPTED SOLUTION

sinhaa

Good solution terentino. As an alternative which completely gives date in format ddMMyyyy is the below function.

 

====

def GetDate(hello) {
import java.util.*;
import java.text.SimpleDateFormat;

return new SimpleDateFormat("ddMMyyyy").format(Calendar.getInstance().getTime());
}

 

====

 

Call it the same way like GetDate(1).

 

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

5 REPLIES 5

CLAYTONJS

That is perfect guys. Thank you very much. You have made my life much easier and my WFA workflows a lot cleaner.

 

Cheers,

Clayton

Siegfried

Above solutiuons caused a syntax error on my system, so I created this one : 

 

def getDate(dateFormat) {

// dateFormat - string for SimpleDateFormat

import java.text.SimpleDateFormat;
import java.util.Date;
Date curDate = new Date();
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
String DateToStr = format.format(curDate);
return (DateToStr);
}

 

 You call it : getDate('yyyy_MM_dd')

Adai

Hi Clayton,

          I got this from one of the community contributors, bestinj.

 

def getDate(data)
{
java.util.Calendar cal= java.util.Calendar.getInstance(java.util.Locale.getDefault()) ;
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("HH-mm-MM-dd-yy");
return format.format(cal.getTime());
}

 

Call the function as getDate(1)

 

 

Thanks to bestinj for the help

 

You can play with the SimpleDateFormat("HH-mm-MM-dd-yy") for different date formats.

 

Hope this helps.

 

Regards

adai

 

 

sinhaa

Good solution terentino. As an alternative which completely gives date in format ddMMyyyy is the below function.

 

====

def GetDate(hello) {
import java.util.*;
import java.text.SimpleDateFormat;

return new SimpleDateFormat("ddMMyyyy").format(Calendar.getInstance().getTime());
}

 

====

 

Call it the same way like GetDate(1).

 

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

trentino123

Hi Clayton,

 

Try a new function with this MVEL code :

 

def Timestamp(hello) {

import java.util.Date;

d=new Date();

 return d;

}

 

During the test call it with Timestamp(1) , so it is not empty in the inputs, the number 1 is not used.

 

Hope it helps.

 

Thanks!

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public