Actually my java program like…
public class Schedule {
public static enum RepeatType {
DAILY, WEEKLY, MONTHLY;
}
public static enum WeekdayType {
MONDAY(Calendar.MONDAY), TUESDAY(Calendar.TUESDAY),
WEDNESDAY(Calendar.WEDNESDAY), THURSDAY(Calendar.THURSDAY),
FRIDAY(Calendar.FRIDAY), SATURDAY(Calendar.SATURDAY), SUNDAY(Calendar.SUNDAY);
private int day;
private WeekdayType(int day) {
this.day = day;
}
public static List<Date> generateSchedule(RepeatType repeatType,List<WeekdayType> repeatDays) {
// ...
// here some logic i wrote
}
}
}
And i’m calling the method into my Business class like following…
@RemotingInclude
public void createEvent(TimetableVO timetableVO) {
if ("repeatDays".equals(timetableVO.getSearchKey())) {
List<Date> repeatDaysList = Schedule.generateSchedule(timetableVO.getRepeatType() , timetableVO.getRepeatDays());
}
}
And Finally TimetableVO is
@Entity
@Table(name="EC_TIMETABLE")
public class TimetableVO extends AbstractVO {
// ...
private RepeatType repeatType;
// But in this case the method generateSchedule(-,-) was not calling.
private List<WeekdayType> repeatDays;
// ...
}
So my Question is Which one is Better Statement in the Following…
private List<WeekdayType> repeatDays;
(or)
// If we give like this `How to Convert Enum type to String` because generateSchedule() method taking enum type value....
private String repeatDays;
The value of any enumerated type can be converted to a String using the toString() method. You might not have realized (I didn’t at first) that if you declare a
RepeatTypevariabler1, thenr1can be converted to aStringusing thetoString()method E.G.r1.toString()This Program:
Will Output the actual Enum Values as Follows: