Java Week Day getDayOfWeek(Date dt)

Here you can find the source of getDayOfWeek(Date dt)

Description

Get and return the day of week from the given Date dt

License

Open Source License

Parameter

Parameter Description
dt The given Date

Return

day The abbreviated String value of the day

Declaration

public static String getDayOfWeek(Date dt) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    /**//from www  .  jav  a2 s . c o  m
     * Get and return the day of week from the given Date dt
     * 
     * @param dt
     *            The given Date
     * 
     * @return day The abbreviated String value of the day
     */
    public static String getDayOfWeek(Date dt) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(dt);
        int dow = cal.get(Calendar.DAY_OF_WEEK);
        switch (dow) {
        case 1:
            return "SUN";
        case 2:
            return "MON";
        case 3:
            return "TUE";
        case 4:
            return "WED";
        case 5:
            return "THU";
        case 6:
            return "FRI";
        case 7:
            return "SAT";
        default:
            return "";
        }
    }
}

Related

  1. getDayOfWeek(Date date)
  2. getDayOfWeek(Date date)
  3. getDayOfWeek(Date date)
  4. getDayOfWeek(Date date)
  5. getDayOfWeek(Date date, int day)
  6. getDayOfWeek(Date start, int day)
  7. getDayOfWeek(int _year, int _month, int _day)
  8. getDayOfWeek(int year, int month, int day)
  9. getDayOfWeek(long date)