Android Week Get getEnglishDayInWeek(Date date)

Here you can find the source of getEnglishDayInWeek(Date date)

Description

Returns the first letter of day in week.

Parameter

Parameter Description
date a parameter

Declaration

public static char getEnglishDayInWeek(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**//  w w w . j a  v a  2s .  co  m
     * Returns the first letter of day in week.
     * For example, Monday will return 'M'.
     * @param date
     * @return
     */
    public static char getEnglishDayInWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int dayInWeek = c.get(Calendar.DAY_OF_WEEK);
        switch (dayInWeek) {
        case Calendar.MONDAY:
            return 'M';
        case Calendar.TUESDAY:
            return 'T';
        case Calendar.WEDNESDAY:
            return 'W';
        case Calendar.THURSDAY:
            return 'T';
        case Calendar.FRIDAY:
            return 'F';
        case Calendar.SATURDAY:
            return 'S';
        case Calendar.SUNDAY:
        default:
            return 'S';
        }
    }
}

Related

  1. getDateInAWeek(Date date)
  2. getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek)
  3. getStartAndEndDatesForWeek(Calendar currentDate, Calendar startDate, Calendar endDate)
  4. getDaysOfWeekNames()
  5. getDaysOfWeekNames(Locale l, int len)
  6. getFirstDayOfFirstWeekOfMonth(final Calendar cal)