【发布时间】:2022-12-28 16:30:33
【问题描述】:
LocalDate currentdate = LocalDate.now();
Month currentMonth = currentdate.getMonth();
FrequencyEntity frequencyEntity = null;
switch (currentMonth) {
case Month.JANUARY: // Here.
frequencyEntity = FrequencyEntity.builder().january(frequency).build();
}
我注释为“此处”的行导致我的 IDE 显示:“枚举开关大小写标签必须是枚举常量的非限定名称。”。
我能想到的唯一可能的解决方案是将月份转换为字符串。但这可能不是一个正确的解决方案。
你能帮我找到一个更优雅的方式吗?
【问题讨论】:
-
试试 JANUARY
标签: java