[ https://issues.apache.org/jira/browse/GROOVY-11513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17895044#comment-17895044 ]
Scott edited comment on GROOVY-11513 at 11/2/24 6:10 PM: --------------------------------------------------------- Doesn't it seem like this should be default behavior considering java.util.Date is already a global import? Usage of Date classes is extremely common and the migration away from Date is quite slow because the requirement of additional imports. It seems counterintuitive to have java.util.Date imported automatically, but not have java.time.DateTime considering the percentage of groovy projects that do some form of date/time manipulation? More specific, there is a strong need for Date manipulation inside groovy web projects for Date manipulation WITHOUT import. For instance importing java.time.DateTime is quite inconvenient in a gsp page. Currently you have to do something like this: <%@ page import="java.time.LocalDateTime" %> and you might even have to do this multiple times on the same page if you use templates. was (Author: JIRAUSER284944): Doesn't it seem like this should be default behavior considering java.util.Date is already a global import? Usage of Date classes is extremely common and the migration away from Date is quite slow because the requirement of additional imports. More specific, there is a strong need for Date manipulation inside groovy web projects for Date manipulation WITHOUT import. For instance importing java.time.DateTime is quite inconvenient in a gsp page. > java.time.* should be imported automatically > -------------------------------------------- > > Key: GROOVY-11513 > URL: https://issues.apache.org/jira/browse/GROOVY-11513 > Project: Groovy > Issue Type: Improvement > Components: Compiler > Affects Versions: 4.0.23 > Reporter: Scott > Priority: Major > Fix For: 4.x > > > if java.time is the recommended way to proceed forward when dealing with > dates, > java.time.* should be included automatically similar to how java.util.Date is > currently available without import. > The preferred approach would be to make it a global import which would be in > line with existing Groovy handling of java.util.Date > > The least invasive approach would be to make the import only apply if > groovy-datetime module has been added. > > implementation "org.apache.groovy:groovy-datetime" > > should automatically import java.time.* to all classes > > This provides an easier migration path from Date -> DateTIme -- This message was sent by Atlassian Jira (v8.20.10#820010)