GuyWhoReadsStockoverflow GuyWhoReadsStockoverflow - 2 years ago 155
Android Question

How can I extract date from CalendarView and display selected date?

Currently I am using code below and I can get current date to be dispalyed in Text field. However I have no idea how to display selected date.

I also used DatePicker and it displays selected date fine, however I would prefer CalendarView. Thanks

Calendar c = Calendar.getInstance();
SimpleDateFormat ss = new SimpleDateFormat("dd-MM-yyyy");
Date date = new Date();
String currentdate= ss.format(date);
TextView editText = (TextView) this.findViewById(;

Answer Source

in onCreate :

 CalendarView v = new CalendarView( this );
 v.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
    public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
       this.calendar = new GregorianCalendar( year, month, dayOfMonth );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download