Reputation: 46479
I'm trying to get a date from calendar view:
calendar = (CalendarView) findViewById(R.id.calendarView);
by trying:
String selectedDate = calendar.getDate().toString();
But am getting error saying that toString()
method can not be resolved
I would like to further get it in a format of "DD/MM/YYYY"
Upvotes: 4
Views: 15846
Reputation: 2445
You should use SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String selectedDate = sdf.format(new Date(calendar.getDate()));
Upvotes: 9