datepicker selected day of the week android

后端 未结 3 1630
太阳男子
太阳男子 2021-01-13 04:20

I have date picker in my application and its works well .But I need selected day of week instead of date (i.e., if I select the date 23 I need to get day like \"friday\" ins

3条回答
  •  终归单人心
    2021-01-13 05:14

    change your code as for getting day of week using SimpleDateFormat :

    private DatePickerDialog.OnDateSetListener 
         datePickerListener = new  DatePickerDialog.OnDateSetListener() 
    {       
        public void onDateSet(DatePicker view, int selectedYear,
            int selectedMonth, int selectedDay) 
        {   
          SimpleDateFormat simpledateformat = new SimpleDateFormat("EEEE");
          Date date = new Date(selectedYear, selectedMonth, selectedDay-1);
          String dayOfWeek = simpledateformat.format(date);
        }
    }
    

提交回复
热议问题