edit_event_time.setClickable(true);
edit_event_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a");
String time = sdf.format(calendar.getTime());
Log.e("time", "time " + sdf.format(calendar.getTime()));
String inputTime = time, inputHours, inputMinutes;
inputHours = inputTime.substring(0, 2);
inputMinutes = inputTime.substring(3, 5);
TimePickerDialog mTimePicker = new TimePickerDialog(DashBoardActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
if (selectedHour == 0) {
selectedHour += 12;
timeFormat = "AM";
} else if (selectedHour == 12) {
timeFormat = "PM";
} else if (selectedHour > 12) {
selectedHour -= 12;
timeFormat = "PM";
} else {
timeFormat = "AM";
}
String selectedTime = selectedHour + ":" + selectedMinute + " " + timeFormat;
edit_event_time.setText(selectedTime);
}
}, Integer.parseInt(inputHours), Integer.parseInt(inputMinutes), true);//mention true for 24 hour's time format,false for 12 hour's time format
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});