I have a string as follows:
"[Monday, Tuesday]"
I want to convert this string to a list of enums of type "Day". My "Day" enum is as follows:
public enum Day {
Monday,Tuesday;
}
I obtained my input string by calling toString() on a List of "Day"s. As follows:
List<Day> days = new ArrayList<Day>();
days.add(Day.Monday);
days.add(Day.Tuesday);
String input = days.toString();
I know that I can parse the input string by commas and brackets. But, is there any efficient way to do this?
To repeat, I want to covert string to a list of enums.
** EDIT **
Question is not just about converting String to enum and vice versa. It involves lists and string parsing.