Java Month of Year getStrDayOfWeek(int _year, int _month, int _day)

Here you can find the source of getStrDayOfWeek(int _year, int _month, int _day)

Description

get Str Day Of Week

License

Open Source License

Declaration

public static String getStrDayOfWeek(int _year, int _month, int _day) 

Method Source Code


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

public class Main {
    public static String getStrDayOfWeek(int _year, int _month, int _day) {
        int dayofweek = getDayOfWeek(_year, _month, _day);
        String res;//from  ww w.j a  va 2s .co m

        switch (dayofweek) {
        case 1:
            res = "Sun";
            break;
        case 2:
            res = "Mon";
            break;
        case 3:
            res = "Tue";
            break;
        case 4:
            res = "Wed";
            break;
        case 5:
            res = "Thu";
            break;
        case 6:
            res = "Fri";
            break;
        case 7:
            res = "Sat";
            break;
        default:
            res = null;
        }

        return res;
    }

    public static int getDayOfWeek(int _year, int _month, int _day) {
        int year, month, date;

        Calendar cal = Calendar.getInstance();
        cal.set(_year, _month - 1, _day);

        return cal.get(Calendar.DAY_OF_WEEK);
    }
}

Related

  1. getPreviousDay(int year, int month, int day, int days)
  2. getPrevMonth(String divisionDate, int day, String outputFormat)
  3. getPreYearMonth()
  4. getSecondsOfMonth(int year, int month)
  5. getStartAndEndOfMonth(int month, int year)
  6. getThisMonth(int year, int monthIndex)
  7. getTime(int year, int month, int day)
  8. getTimeByYMD(int year, int month, int day)
  9. getTimestamp(int year, int month, int day, int hour, int minute, int second, int millisecond)