Is it possible to Store Enum value in String?

Posted by Narasimham K on Stack Overflow See other posts from Stack Overflow or by Narasimham K
Published on 2012-12-14T05:00:34Z Indexed on 2012/12/14 5:03 UTC
Read the original article Hit count: 101

Filed under:
|
|

Actally my java progrem 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) {
-----------------------------
----------------------------//hear some logic i wrote
}//Method
}

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;

    private List<WeekdayType> repeatDays;//But in this case the method generateSchedule(-,-) was not calling.
-----
}

So my Question is Which one is Better Statement in the Following...

 private List<WeekdayType> repeatDays;
(or)
private String repeatDays;//if we give like this `How to Convert Enum type to String` because generateSchedule() method taking enum type value....

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate