Date.format() no signature of method

public String generateEmail () {
	Date today = new Date();
	String todaysDate = today.format('YYYYMMdd');
	String nowTime = today.format('HHmmss');
	String email = ((('ua-' + todaysDate) + 'T') + nowTime) + '';
	return email;

I use the above code in two different projects. In the first project, everything works as expected. In the second project(which was made more recently), Katalon does not recognize either .format() method, as shown by the runtime error. The entire class was copied from the working project. I also tried using the following code and it produced the same issue on the .format() methods, as suggested in Katalon Studio 7.9 rc - Bug in Date().format(<String>).

public String generateEmail () {
	Date today = new Date();
	SimpleDateFormat date = new SimpleDateFormat('YYYYMMdd');
	SimpleDateFormat time = new Date('HHmmss');
	String email = ((('ua-' + date.format(today)) + 'T') + time.format(today)) + '';
	return email;

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.MyKeywords.Date.format() is applicable for argument types: (java.lang.String) values: [YYYYMMdd]
Possible solutions: getAt(java.lang.String), print(, print(java.lang.Object)
at com.MyKeywords.Email.invokeMethod(Email.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(
at com.kms.katalon.core.main.TestCaseExecutor.runScript(
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(
at com.kms.katalon.core.main.TestCaseExecutor.execute(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain.runTestCase(
at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)
Caused by: groovy.lang.MissingMethodException: No signature of method: com.MyKeywords.Date.format() is applicable for argument types: (java.lang.String) values: [YYYYMMdd]
Possible solutions: getAt(java.lang.String), print(, print(java.lang.Object)
at com.MyKeywords.Email.generateEmail(Email.groovy:10)
ā€¦ 14 more

You need to ensure you import the necessary resource file: How to add days & years to current date

You have probably noticed already that on the first line you correctly create a new SimpleDateFormat object, however, on the second line you arenā€™t. Fix that and then review @Dave_Evers link.

This message proves that you have a class com.MyKeywords.Date. This naming is horrible. You should never name your class as Date because it will confuse people.

When you write in a Test Case,

new Date('HHmmss')

You may expect to get an instance of com.MyKeyword.Date class, but others (@Dave_Evers, @grylion54, and I) would think you want to create an instance of java.util.Date. But the constructor signature Date(String s) was deprecated years ago, and would not work. So they would get confused.

If I were you, I would rename your class to be unique; for example, rename com.MyKeywords.Date to my.keywords.MyWonderfulDate.

I would advise you; you should no longer use java.util.Date and SimpleDateFormat class. These are decades old and poorly designed.

Java 8 introduced new (but already 7 years old) Date/Time API to replace the classic Date and Calendar API.

Java 8 Date/Time (java.time.LocalDateTime and java.time.format.DateTimeFormatter) is far better than the classic. No reason to continue using classics ( java.util.Date and java.text.SimpleDateFormat).

See the following article to learn the new API:

As @kazurayam reminded meā€¦
I should be using ā€˜java.time.LocalDateTimeā€™ and ā€˜java.time.format.DateTimeFormatterā€™
Going forward thatā€™s what I will be doing.

//Add these imports to the top of your test cases from script mode.
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

Here are some samples of what I will be using (they can be added to Keywords where needed).

//Get CurrentDateTime with different formatters
LocalDateTime cDateTime =;
//DateTimeFormatter CurrentDate_formatter = DateTimeFormatter.ISO_DATE_TIME;
//DateTimeFormatter CurrentDate_formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
//DateTimeFormatter CurrentDate_formatter = DateTimeFormatter.ofPattern("MM-dd-yyyy-HH:mm:ss");
DateTimeFormatter CurrentDate_formatter = DateTimeFormatter.ofPattern("MM-dd-yyyy-hh:mm:ss");
def CurrentDateTime = cDateTime.format(CurrentDate_formatter);
println("CurrentDateTime: " + CurrentDateTime);
//Create FutureDateTime with different formatters
LocalDateTime fDateTime = localDateTime.plusYears(3);
//DateTimeFormatter FutureDate_formatter = DateTimeFormatter.ISO_DATE_TIME;
//DateTimeFormatter FutureDate_formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd:HH:mm:ss");
//DateTimeFormatter FutureDate_formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd:hh:mm:ss");
DateTimeFormatter FutureDate_formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
def FutureDateTime = fDateTime.format(FutureDate_formatter);
println("FutureDateTime: " + FutureDateTime);
//Create 20 year-old-Birthdate
LocalDateTime bDateTime = localDateTime.minusYears(20)
//LocalDateTime bDateTime = localDateTime.minusYears(20).minusMonths(1).minusDays(1);
DateTimeFormatter BirthDate_formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
def BirthDateTime = bDateTime.format(BirthDate_formatter);
println("Birthdate: " + BirthDateTime);

//Other Date Time Calculations methods:
1 Like