Convert String month to integer java

后端 未结 2 1638
无人及你
无人及你 2021-01-15 15:03

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 mo

2条回答
  •  粉色の甜心
    2021-01-15 15:49

    Calendar cal = Calendar.getInstance();
    cal.setTime(new SimpleDateFormat("MMM").parse("July"));
    int monthInt = cal.get(Calendar.MONTH) + 1;
    

    See

    • IDE one demo

提交回复
热议问题