how to get current date and time in textView android
i am using following code
Calendar c1 = Calendar.getInstance(); SimpleDateFormat sdf1 = new SimpleDateFormat("d / MMM / yyyy"); String strdate1 = sdf1.format(c1.getTime()); TextView txtdate1 = (TextView) findViewById(R.id.current_date_view); txtdate1.setText(strdate1); Calendar c2 = Calendar.getInstance(); SimpleDateFormat sdf2 = new SimpleDateFormat("h : MM : a"); String strdate2 = sdf2.format(c2.getTime()); TextView txtdate2 = (TextView) findViewById(R.id.current_time_view); txtdate2.setText(strdate2);
but this is not working below API 23