//get current date
SimpleDateFormat monthFormat = new SimpleDateFormat("M");
int _currentMonth = Integer.parseInt(monthFormat.format(new Date(System.currentTimeMillis())));
SimpleDateFormat yearFormat = new SimpleDateFormat("YYYY");
int _currentYear = Integer.parseInt(yearFormat.format(new Date(System.currentTimeMillis())));
I’m trying to build a calendar view and I’m starting by retrieving the currrent year and month. However, what is returned is a string, whereas I want a int to use in arrays etc..
The code posted above is giving me an error most likely due to the Integer.parseInt function.
Can I not use it? What is the best way of retrieving the year, month, and day.
Change “M” to “MM” and “YYYY” to “yyyy”.