groovy.lang.MissingMethodException No signature of method: java.util.GregorianCalendar.format()

No signature of method: java.util.GregorianCalendar.format() is applicable for argument types: (String) values: [yyyy-MM-dd HH:mm:ss]

Possible solutions: from(java.time.ZonedDateTime), toYear(), stream(), getAt(java.lang.String), print(java.lang.Object), print(java.io.PrintWriter)

at e2ebase.LangUtil.NowAddDaysString(LangUtil.groovy:39)


1 Like

Hi @281558325, Try using “Ctrl + Shift + O” to import any missing packages.

The java.util.GregorianCalendar class provided by Java Runtime Environment v17 does not implement the String format(String) method. Check the javadoc:

https://docs.oracle.com/javase/8/docs/api/java/util/GregorianCalendar.html

However Groovy language provides a class named java.util.GregocianCalendar which designed to extend the JDK and does implement the String format(String) method. Check the groovydoc:

https://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Calendar.html#format(java.lang.String)

I understand that @281558325 expected the format method provided by Groovy to be available for him/her in a script in Katalon Studio; but unfortunately he/she encountered a groovy.lang.MissingMethodException.

A month ago, there was a similar topic which reported a problem about Katalon Studio v9.7.2; an user encountered a groovy.lang.MissingMethodException for java.util.Date.format(String) method. See the following topic:

I believe that @281558325 encountered a problem that comes from the same reason as this previous topic.

A Katalon staff wrote:

I am not sure if any patch for this particular issue has been released yet.

As far as I examined, Katalon Studio good-old v9.0.0 does not have the problem for java.util.Date. See my report:

I think that v9.0.0 would be OK for java.util.GregorianCalendar as well.

So, @281558325 might want to downgrade to v9.0.0 and try to see how it runs.

I would rather recommend @281558325 to rewrite his/her test script so that it does NOT depend on the java.util.GregorianCalendar.format(String) method.

As of Java8, the java.time API is the standard methodology to deal with Date/Time in Java/Groovy programs. You should be able to rewrite your script to use java.time API rather than Groovy’s extension methods like format(String).

To learn the java.time API of JDK8, have a look at the following Baeldung articles:

https://www.baeldung.com/java-8-date-time-intro

The runnable source code is available at tutorials/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime at master · eugenp/tutorials · GitHub

Also

https://www.baeldung.com/current-date-time-and-timestamp-in-java-8

And also

https://www.baeldung.com/java-datetimeformatter

Thank you for your enthusiastic support and assistance;
My katalon studio works greate by following @ Elly_Tran;
Add a groovy-dateutil-3.0.17.jar to “Katalon_Studio_Windows_64-9.7.2\Katalon_Studio_Windows_64-9.7.2\configuration\resources\lib”