Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the week day from a calendarview in android

I have implemented a calendarview in my project, i can get the day of the month, the month and the year, but i cant find any method to get the day of the week, my code is this:

    view = new CalendarView(this);
    setContentView(view);


    view.setOnDateChangeListener(new OnDateChangeListener() {

        @Override
        public void onSelectedDayChange(CalendarView arg0, int year,
                int month, int dateb) { 

And when i choose a day in calendar i would need to get the week day to, I'm trying to get the answer but i cant find.

Sorry for my english.

like image 269
RodyRed Avatar asked Dec 01 '25 16:12

RodyRed


1 Answers

You could always use the Calendar and set it through the time you get from the calendar view:

Calendar selected = Calendar.getInstance();
selected.setTimeInMillis(view.getDate());
int dayOfWeek = selected.get(Calendar.DAY_OF_WEEK);

Each of the int values correspond to one of the days, for example Calendar.TUESDAY = 3

Hope it helps

like image 114
lucianohgo Avatar answered Dec 03 '25 07:12

lucianohgo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!