RodyRed
RodyRed

Reputation: 43

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.

Upvotes: 3

Views: 1822

Answers (1)

lucianohgo
lucianohgo

Reputation: 319

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

Upvotes: 3

Related Questions