Insert a variable into a string and save the current date

Good morning,

I would need help if that is possible.

I wanted to know if with Katalon it is possible to insert a Global variable in a string, for example I have a string variable with a text and at the end of the text I would like to insert a global variable, in this case a date, so that I can make a comparison with what I see on the screen.
I tried to write the variable like this:
Try = "sample text $ {Globalvariable} — but in the end the $ {Globalvarible} is perceived as text and not as a variable, how can you do that at the end of that text the variable is recognized?

one last question is, in Katalon would it be possible to store the current date at the start of the test run?

thank you very much in advance.

Antonino

Here I assume you have a global variable named “FOO” with value “bar”, you should rather write:

text = "sample text ${GlobalVariable.FOO}"
println(text)

Then you will see in the Console:

sample text bar

It is a question about Java/Groovy programming. Let me give you a Test Case script example:

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

//Get current date time
LocalDateTime now = LocalDateTime.now();

println("in default format : " + now);

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

String formatDateTime = now.format(formatter)

println("in custom format : " + formatDateTime)

If you would like, you can learn many from Groovy programming articles on the net, for example: