Get Next Week Day - Java java.util

Java examples for java.util:Week

Description

Get Next Week Day

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(GetNextWeekDay());
    }//w  ww . ja  v  a  2s.  co  m

    private static int GetNextWeekDay() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, 1);

        int weekday = 0;
        switch (cal.DAY_OF_WEEK) {
        case Calendar.MONDAY:
            weekday = 1;
            break;
        case Calendar.TUESDAY:
            weekday = 2;
            break;
        case Calendar.WEDNESDAY:
            weekday = 4;
            break;
        case Calendar.THURSDAY:
            weekday = 8;
            break;
        case Calendar.FRIDAY:
            weekday = 16;
            break;
        case Calendar.SATURDAY:
            weekday = 32;
            break;
        case Calendar.SUNDAY:
            weekday = 64;
            break;
        }
        return weekday;
    }
}

Related Tutorials