-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Not A Bug
-
Affects Version/s: 3.0.5, 2.5.13
-
Fix Version/s: None
-
Component/s: groovy-runtime
-
Labels:None
-
Environment:Ubuntu 18.04.5 LTS
OpenJDK Java 1.8.0_265 (Private Build 25.265-b01)
Gradle 5.6.3
Description
Date.format appears broken in Groovy 2.5 and later.
Example code
// Works in Groovy 2.4.20 but throws groovy.lang.MissingMethodException // in Groovy 2.5.13 and 3.0.5 new Date().format('YYYYMMdd')
Expected behavior
Returns the current date formatted as a string. e.g. 20200901
Actual behavior
Throws exception.
groovy.lang.MissingMethodException: No signature of method: java.util.Date.format() is applicable for argument types: (String) values: [YYYYMMdd] Possible solutions: from(java.time.Instant), stream(), getAt(java.lang.String), parse(java.lang.String), print(java.lang.Object), print(java.io.PrintWriter)
Groovy version matrix
Groovy version | Behavior |
---|---|
2.4.20 | Returns date |
2.5.13 | throws exception |
3.0.5 | throws exception |