How to type Future Date

Hi I’m new using Katalon and I need to enter/type a future date.

At the moment I’m entering the date directly but I want to create a variable with current date in a specific format and pass plus 10 days

WebUI.setText(findTestObject(‘CURA Healthcare Service - Make Appointment/input_Visit Date’), ‘30/11/2023’)

Can someone help me how to do it?


You can do it like you did in your other question, although there are “newer” Date libraries in Java

Date todaysDate = new Date();
def formattedDate = todaysDate.format("dd/MM/yyyy")
def futureDate ="dd/MM/yyyy")

WebUI.sendKeys(findTestObject('CURA Healthcare Service - Make Appointment/input_Visit Date'),futureDate)

todaysDate is a Date data type but “formattedDate” and “futureDate” are cast to String data type because of the format() method.

Edit: And with newer libraries:

import java.time.LocalDate
import java.time.format.DateTimeFormatter

DateTimeFormatter screenFormat = DateTimeFormatter.ofPattern("MM/dd/yyyy")
DateTimeFormatter standardFormat = DateTimeFormatter.ofPattern("M/d/yyyy")

LocalDate localDate =

gFormattedDate = localDate.format(standardFormat)
gScreenFormattedDate = localDate.format(screenFormat)

gTomorrowDate        = localDate.plusDays(1).format(screenFormat)  // future dates
gNextWeekDate        = localDate.plusDays(7).format(screenFormat)

gNextMonthDate       = localDate.plusMonths(1).format(screenFormat)  // future months

gFormattedYesterdayDate = localDate.minusDays(1).format(screenFormat)  // past dates
gLastWeekDate           = localDate.minusDays(7).format(screenFormat)

gLastMonthDate          = localDate.minusMonths(1).format(screenFormat)   // past months

Thanks worked.

Hi @ddorneles I use the following:
Copy and paste the following into a new test case and run it… See this link too: Java LocalDateTime

import java.time.LocalDate as LocalDate
import java.time.format.DateTimeFormatter as DateTimeFormatter

//Formats date using alpha month output
DateTimeFormatter monthDateFormat = DateTimeFormatter.ofPattern('MMM/dd/yyyy')
//Formats date using numeric month output
DateTimeFormatter standardDateFormat = DateTimeFormatter.ofPattern('MM/dd/yyyy')
LocalDate localDate =

//Uses monthDateFormat
monthTodayDate = localDate.format(monthDateFormat)
println(["TodayMonthFormat: " + monthTodayDate])
//Output: [TodayMonthFormat: Nov/22/2023]

//Uses standardDateFormat
todayDate = localDate.format(standardDateFormat)
println(["TodayStandardFormat: " + todayDate])
//Output [TodayStandardFormat: 11/22/2023]

//future dates
Tomorrow = localDate.plusDays(1).format(standardDateFormat)
NextWeek = localDate.plusDays(7).format(standardDateFormat)
println(['Tomorrow: ' + Tomorrow] + ['NextWeek: ' + NextWeek])
//Output: [Tomorrow: 11/23/2023, NextWeek: 11/29/2023]

//future months
NextMonth = localDate.plusMonths(1).format(standardDateFormat)
println(["NextMonth: " + NextMonth])
//Output: [NextMonth: 12/22/2023]

//past dates
Yesterday = localDate.minusDays(1).format(standardDateFormat)
LastWeek = localDate.minusDays(7).format(standardDateFormat)
println(['Yesterday: ' + Yesterday] + ['LastWeek: ' + LastWeek])
//Output: [Yesterday: 11/21/2023, LastWeek: 11/15/2023]

//past months
LastMonth = localDate.minusMonths(1).format(standardDateFormat)
println(["LastMonth: " + LastMonth])
//Output: [LastMonth: 10/22/2023]

//Adds 1 year, 1 month and 1 day to the current date
expirationDate = localDate.plusYears(1)plusMonths(1).plusDays(1)format(standardDateFormat)
println(["FutureExpirationDate: " + expirationDate])
//Output: [FutureExpirationDate: 12/23/2024]

//Good resource:
//Other methods that can be used:
1 Like