日期方法在groovy中无法正常工作

时间:2011-11-20 07:42:04

标签: groovy

我有这个

    class MainController {
    def test = {

    def day1 =1
    def month1 = 10
    def year1 = 2011

    def date1 = new Date(year1 ,month1, day1);
    }
   }

但OutPut是

    Wed Nov 01 00:00:00 PKT 3911

为什么它的3911,不应该是2011年?

任何解决方案

谢谢

1 个答案:

答案 0 :(得分:0)

阅读此弃用构造函数的Date API。你必须在1900年通过。此外,月份从零开始(也在API文档中)。

在我之前的一个问题的回答中也显示了这些信息。