get Next Week Day - Android java.util

Android examples for java.util:Week

Description

get Next Week Day

Demo Code


//package com.java2s;
import java.util.Calendar;

public class Main {
    public static String getNextWeekDay(int next) {
        //First position of forecast is 0
        next++;/* ww w.  j  a v  a  2  s  . c  om*/

        Calendar calendar = Calendar.getInstance();
        int day = calendar.get(Calendar.DAY_OF_WEEK);

        switch (day + next) {
        case Calendar.SUNDAY:
            return "Sunday";
        case Calendar.MONDAY:
            return "Monday";
        case Calendar.TUESDAY:
            return "Tuesday";
        case Calendar.WEDNESDAY:
            return "Wednesday";
        case Calendar.THURSDAY:
            return "Thursday";
        case Calendar.FRIDAY:
            return "Friday";
        case Calendar.SATURDAY:
            return "Saturday";
        default:
            //Begin next week
            return getNextWeekDay(next - 8);
        }
    }
}

Related Tutorials