1 回答
TA贡献1909条经验 获得超7个赞
火库数据库不支持枚举数据类型。若要查看有关支持的数据类型的详细信息,请检查支持的数据类型
解决方案1:(最简单的)只需使用字符串即可不进行枚举
将星期的日期更改为字符串
String dayOfTheWeek; // Changed from Day to String
public SingleOpeningHours(String dayOfTheWeek,String openingTime, String closingTime){
this.dayOfTheWeek = dayOfTheWeek;
this.openingTime = openingTime;
this.closingTime = closingTime;
}
并在单个打开时间列表中使用字符串,如下所示,
ArrayList<SingleOpeningHours> singleOpeningHours = new ArrayList<SingleOpeningHours>();
singleOpeningHours.add(new SingleOpeningHours("MONDAY", "09:00", "00:00"));
singleOpeningHours.add(new SingleOpeningHours("TUESDAY", "09:00", "01:00"));
解决方案 2:将“单打开时间”对象中使用的“每周”日期更改为字符串,并在枚举类中使用 name() 方法将枚举值转换为字符串
String dayOfTheWeek; // Changed from Day to String
String openingTime;
String closingTime;
public SingleOpeningHours(Day dayOfTheWeek,String openingTime, String closingTime){
this.dayOfTheWeek = dayOfTheWeek.name(); // make sure add .name()
this.openingTime = openingTime;
this.closingTime = closingTime;
}
并在单个打开时间列表中使用枚举日(此处无更改)
ArrayList<SingleOpeningHours> singleOpeningHours = new ArrayList<SingleOpeningHours>();
singleOpeningHours.add(new SingleOpeningHours(Day.MONDAY, "09:00", "00:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.TUESDAY, "09:00", "01:00"));
希望这些解决方案将帮助您解决问题
添加回答
举报