You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/09/01 07:55:00 UTC

[jira] [Comment Edited] (GROOVY-9709) Date.format throws groovy.lang.MissingMethodException

    [ https://issues.apache.org/jira/browse/GROOVY-9709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17188234#comment-17188234 ] 

Paul King edited comment on GROOVY-9709 at 9/1/20, 7:54 AM:
------------------------------------------------------------

The {{groovy-dateutil}} module was made optional in 2.5 since the {{java.time}} classes (JSR-310) are now generally preferred (and are included by default). If you just add that module to your project dependencies you will also get the old behavior.

See the first bullet point under breaking changes in the release notes:
 [http://groovy-lang.org/releasenotes/groovy-2.5.html#Groovy2.5releasenotes-Breakingchanges]


was (Author: paulk):
The {{groovy-dateutil}} module was made optional in 2.5 since the {{java.time}} classes (JSR-310) are now generally preferred (and are included by default). If you just add that module to your project dependencies you will also get the old behavior.

 

See the first bullet point under breaking changes in the release notes:
[http://groovy-lang.org/releasenotes/groovy-2.5.html#Groovy2.5releasenotes-Breakingchanges]

> Date.format throws groovy.lang.MissingMethodException
> -----------------------------------------------------
>
>                 Key: GROOVY-9709
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9709
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.5, 2.5.13
>         Environment: Ubuntu 18.04.5 LTS
> OpenJDK Java 1.8.0_265 (Private Build 25.265-b01)
> Gradle 5.6.3
>            Reporter: Sam Gleske
>            Priority: Major
>
> h2. Description
> [Date.format|http://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/Date.html#format(java.lang.String,%20java.util.TimeZone)] appears broken in Groovy 2.5 and later.
> h2. Example code
> {code:java}
> // Works in Groovy 2.4.20 but throws groovy.lang.MissingMethodException
> // in Groovy 2.5.13 and 3.0.5
> new Date().format('YYYYMMdd'){code}
> h2. Expected behavior
> Returns the current date formatted as a string.  e.g. 20200901
> h2. Actual behavior
> Throws exception.
> {noformat}
> 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){noformat}
> h2. Groovy version matrix
> ||Groovy version||Behavior||
> |2.4.20|Returns date|
> |2.5.13|throws exception|
> |3.0.5|throws exception|



--
This message was sent by Atlassian Jira
(v8.3.4#803005)