To provide current date and timestamp as an input to sendkeys method

How to provide the current date and timestamp as an input to the date field textbox using katalon?.
Timestamp format : 26-MAY-2021 19:32.
Please provide solution.

How about:

Date todaysDate = new Date();
def formattedDate = todaysDate.format("dd-MMM-yyyy HH:MM");

WebUI.setText(findTestObject('myPage/myDate'), formattedDate)

WebUI.verifyElementAttributeValue(findTestObject('myPage/myDate'), "value", formattedDate, 10)

Thanks for solution. it is not taking the correct time value. there was 30 minutes difference while using the date function.

for e.g system time : 22:30
value passed : 22: 05

My bad. Instead of using the minute reference of Date, I used the Month. SIGH. How about try the hour and minute as lower-case or the hour as upper-case and the minute as lowercase?

Date todaysDate = new Date();
def formattedDate = todaysDate.format("dd-MMM-yyyy hh:mm");


def formattedDate = todaysDate.format("dd-MMM-yyyy HH:mm");

Saying that, I see on some websites that the Date is not appropriate for returning the time portion. It will work for this, but not for something complicated. You can do some review of this yourself.

Then you have to take Time Zone Difference into account.

Sample code:

import java.time.OffsetDateTime as OffsetDateTime
import java.time.ZoneOffset as ZoneOffset
import java.time.format.DateTimeFormatter as DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder as DateTimeFormatterBuilder
import java.util.Locale as Locale

println("Now it is ...")

nowInTokyo = nowIn(ZoneOffset.of('+09:00'))
println('in Tokyo: ' + nowInTokyo)

nowInDelhi = nowIn(ZoneOffset.of('+05:30'))
println('in Delhi: ' + nowInDelhi)

nowInBerlin = nowIn(ZoneOffset.of('+02:00'), Locale.GERMANY)
println('in Berlin: ' + nowInBerlin)

nowInBuenosaires = nowInZoneOffsetOf(ZoneOffset.of('-03:00'))
println('in Brenos Aires:' + nowInBuenosaires)

def nowIn(ZoneOffset zo = ZoneOffset.of('+00:00'), Locale language = Locale.ENGLISH) {
    OffsetDateTime now =
    DateTimeFormatter dtf = new DateTimeFormatterBuilder().parseCaseInsensitive()
		.appendPattern('dd-MMM-yyyy HH:mm').toFormatter(language)
    return dtf.format(now).toUpperCase()


Now it is ...

in Tokyo: 27-MAY-2021 10:19
in Delhi: 27-MAY-2021 06:49
in Berline: 27-MAI-2021 03:19
in Brenos Aires:26-MAY-2021 22:19