How to get today's DayOfWeek

Hi, I am trying to get today’s day of the week by using a custom script. The code is as shown below.

import java.util.Calendar
@CustomScriptAction(
output='date_str'
)

def customScript(){
   def date = new Date()
	Calendar calendar = Calendar.getInstance()
	calendar.setTime(date);
	def day = calendar.get(Calendar.DAY_OF_WEEK);
}

But I am getting error as : cannot cast java.util.LinkedHashMap to com.workfusion.studio.rpa.recorder.api.types.RDataType

can any help. Thank You.

1 Like

Hi, @mjana do you need to get the day as a String?

You can do it via Constant Value action

Custom script:

@CustomScriptAction(
output = 'week_day'
)

def customScript() {
week_day = RString.of("${RDateTime.now().getDayOfWeek()}")
} 
1 Like