首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java时区枚举中的Eclipse变量错误

Java时区枚举中的Eclipse变量错误
EN

Stack Overflow用户
提问于 2012-05-19 01:52:56
回答 1查看 716关注 0票数 1

当我在我的时区枚举中声明一个最终的TimeZone tz变量时,我得到了一个错误。我在http://snipplr.com/view/23131/timezone-enum/上找到了这个枚举的示例,但是Eclipse给了我一个“标记tz上的语法错误”,我不知道为什么。我已经用几种方法重新配置了代码,但这似乎是最好的方法,并且Eclipse不喜欢它。

代码语言:javascript
复制
import java.util.TimeZone;

public enum TimeZoneEnum {

    DEFAULT(TimeZone.getDefault()),
    ETC_GMT_PLUS_12(TimeZone.getTimeZone("Etc/GMT+12")),
    ETC_GMT_PLUS_11(TimeZone.getTimeZone("Etc/GMT+11")),
    ETC_GMT_PLUS_10(TimeZone.getTimeZone("Etc/GMT+10")),
    ETC_GMT_PLUS_9(TimeZone.getTimeZone("Etc/GMT+9")),
    ETC_GMT_PLUS_8(TimeZone.getTimeZone("Etc/GMT+8")),
    ETC_GMT_PLUS_7(TimeZone.getTimeZone("Etc/GMT+7")),
    ETC_GMT_PLUS_6(TimeZone.getTimeZone("Etc/GMT+6")),
    ETC_GMT_PLUS_5(TimeZone.getTimeZone("Etc/GMT+5")),
    ETC_GMT_PLUS_4(TimeZone.getTimeZone("Etc/GMT+4")),
    ETC_GMT_PLUS_3(TimeZone.getTimeZone("Etc/GMT+3")),
    ETC_GMT_PLUS_2(TimeZone.getTimeZone("Etc/GMT+2")),
    ETC_GMT_PLUS_1(TimeZone.getTimeZone("Etc/GMT+1")),
    ETC_GMT_PLUS_0(TimeZone.getTimeZone("Etc/GMT+0")),
    ETC_GMT_MINUS_1(TimeZone.getTimeZone("Etc/GMT-1")),
    ETC_GMT_MINUS_2(TimeZone.getTimeZone("Etc/GMT-2")),
    ETC_GMT_MINUS_3(TimeZone.getTimeZone("Etc/GMT-3")),
    ETC_GMT_MINUS_4(TimeZone.getTimeZone("Etc/GMT-4")),
    ETC_GMT_MINUS_5(TimeZone.getTimeZone("Etc/GMT-5")),
    ETC_GMT_MINUS_6(TimeZone.getTimeZone("Etc/GMT-6")),
    ETC_GMT_MINUS_7(TimeZone.getTimeZone("Etc/GMT-7")),
    ETC_GMT_MINUS_8(TimeZone.getTimeZone("Etc/GMT-8")),
    ETC_GMT_MINUS_9(TimeZone.getTimeZone("Etc/GMT-9")),
    ETC_GMT_MINUS_10(TimeZone.getTimeZone("Etc/GMT-10")),
    ETC_GMT_MINUS_11(TimeZone.getTimeZone("Etc/GMT-11")),
    ETC_GMT_MINUS_12(TimeZone.getTimeZone("Etc/GMT-12")),
    ETC_GMT_MINUS_13(TimeZone.getTimeZone("Etc/GMT-13")),
    ETC_GMT_MINUS_14(TimeZone.getTimeZone("Etc/GMT-14")),

    private final TimeZone tz;

    private TimeZoneEnum(final TimeZone tz) {
        this.tz = tz;
    }

    public final TimeZone getTimeZone() {
        return tz;
    }

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-19 01:54:42

代码语言:javascript
复制
ETC_GMT_MINUS_14(TimeZone.getTimeZone("Etc/GMT-14"));
                                                    ^-- notice the semicolon here 
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10657455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档