Get Week Day - Java java.util

Java examples for java.util:Week

Description

Get 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(GetWeekDay());
    }/*  w  ww.  ja v  a2  s  .  com*/

    private static int GetWeekDay() {
        Calendar cal = Calendar.getInstance();
        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