我每 30 分钟创建一次时间段。但我不知道如何在数组中标记周一到周五的每个时间段。这是我想如何标记我的时间段的示例。
MS1 -> Monday 0800-0830
MS2 -> Monday 0830-0900
.
.
TS1 -> Tuesday 0800-0830
TS2 -> Tuesday 0830-0900
...
FS16 -> Friday 0530->0600
//create date(day and time)
public static Date newDate(Day day, int hour, int minute){
return new Date(day, new TimeSlot(hour, minute));}
//create date with parameters
public static Date newDate(Day day, int minute){
return new Date(day, new TimeSlot(minute));}
这就是我在时隙类中创建我的时隙的方式。
//getter for hour
public int getHour(){return hour;}
//param hour the hour to set
public void setHour(int hour){
//24 hours
if((hour >= 0) && (hour < 24)){
this.hour = hour;}}
//getter for minute
public int getMinute(){return minute;}
//param minute the minute to set
public void setMinute(int minute){
if(minute >0){
this.hour += minute/60;
this.minute = 30 * ((minute % 60) / 30);}
else{
minute = 0;}}
所以如果我使用二维数组存储。会是这样吗?所以价值指数表示每30分钟aite?
mondayTimeSlot.add(new TimeSlot(0));
mondayTimeSlot.add(new TimeSlot(1));
....
fridayTimeSlot.add(new TimeSlot(15));