Set the date format

Hi everyone,

My application is using the date format as 02 July 2019 and time format as HH:MM

How can i set the current date and currrent time also please help me to increament the date and time as well.

I am using this code

Date today = new Date()
String todaysDate = today.format(‘dd mm yyyy’)
String nowTime = today.format(‘HH:MM’)
WebUI.comment("todays date is " +todaysDate)
WebUI.comment("todays date is " +nowTime)

Thanks in advance

You should learn Java 8 java.time.LocalDate and java.time.LocalDateTime.


As this article says:

Before Java 8, the standard Java date and time libraries weren’t very user-friendly. Hence, Joda-Time became the de facto standard date and time library for Java prior to Java 8.

In Katalon Studio, you can use Java 8: java.time.LocalDate and java.tile.LocalDateTime. The java.time package is, as far as I see, wonderful. I do not need older libraries: Joda, Apache Commons, java.util.Calendar any longer

def date = new Date()
def formattedDate = date.format(“dd-MMMM-yyy HH:mm”) // 02-July-2019 20:00
System.err.println formattedDate // Prints current date

date=date+1 //You can use minus - OR plus + symbol to add or minus number of days
formattedDate = date.format(“dd-MMMM-yyy HH:mm”)
println formattedDate

Thank you

Hi guys,

I hope everyone doing well…if you guys want to select only a date, please refer the attachment