无法找到匹配的构造函数: java.time.ZonedDateTime()。

huangapple go评论82阅读模式
英文:

unable to find matching constructor for: java.time.ZonedDateTime()

问题

我有一个非常简单的代码库但我感到非常傻为什么会出现错误`groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.time.ZonedDateTime()`

    import org.testng.annotations.Test
    import java.time.ZonedDateTime
    import org.apache.logging.log4j.LogManager
    import org.apache.logging.log4j.Logger
    class timeTests {
        Logger log = LogManager.getLogger(this.class.getName())
        def startTime(){
            return ZonedDateTime.now()
        }
        def endTime(){
            def start = startTime()
            def end = start.plusSeconds(5)
            return end
        }
        @Test
        void test(){
            log.info(endTime())
        }
    }

示例来源:https://www.geeksforgeeks.org/zoneddatetime-now-method-in-java-with-examples/


<details>
<summary>英文:</summary>

i have a very simple code base and i feel really silly here. Why am i getting the error `groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.time.ZonedDateTime()`

    import org.testng.annotations.Test
    import java.time.ZonedDateTime
    import org.apache.logging.log4j.LogManager
    import org.apache.logging.log4j.Logger
    class timeTests {
        Logger log = LogManager.getLogger(this.class.getName())
        def startTime(){
            return new ZonedDateTime().now()
        }
        def endTime(){
            def start = startTime()
            def end = start.plusSeconds(5)
            return end
        }
        @Test
        void test(){
            log.info(endTime())
        }
    }

example taken from: https://www.geeksforgeeks.org/zoneddatetime-now-method-in-java-with-examples/

</details>


# 答案1
**得分**: 4

构造函数不存在。使用 `ZonedDateTime.now()` 函数或其等效函数之一。请参阅相关的 [JavaDoc](https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html)。

<details>
<summary>英文:</summary>

The constructor does not exist. Use `ZonedDateTime.now()` or one of the equivalents. See the relevant [JavaDoc](https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html).

</details>



huangapple
  • 本文由 发表于 2020年8月24日 23:01:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63563576.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定