Convert String Month To Integer Java
How do I convert a month string to integer? On click method I want to display the date which is selected but if the date has an event it should display something more about the ev
Solution 1:
Calendar cal = Calendar.getInstance();
cal.setTime(new SimpleDateFormat("MMM").parse("July"));
int monthInt = cal.get(Calendar.MONTH) + 1;
See
Solution 2:
There are only 12 month, so just normalize the string and just do string comparison. I wouldn't try to over-optimize.
Post a Comment for "Convert String Month To Integer Java"