Java Day Name getCurrentDayName()

Here you can find the source of getCurrentDayName()

Description

Get current day name (sunday, ...

License

Apache License

Parameter

Parameter Description

Declaration

public static String getCurrentDayName() 

Method Source Code

//package com.java2s;
/*/*from w w w  .  j a  va 2s .c  o  m*/
 * Licensed to Eolya and Dominique Bejean under one
 * or more contributor license agreements. 
 * Eolya licenses this file to you under the 
 * Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    /**
     * Get current day name (sunday, ... , saturday)
     * 
     * @param 
     * @return
     */
    public static String getCurrentDayName() {
        Calendar cal = new GregorianCalendar();
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);

        switch (dayOfWeek) {
        case 1:
            return "sunday";
        case 2:
            return "monday";
        case 3:
            return "thursday";
        case 4:
            return "wednesday";
        case 5:
            return "tuesday";
        case 6:
            return "friday";
        case 7:
            return "saturday";
        }
        return "";
    }
}

Related

  1. dayName(String dayNumber)
  2. dayName(String dayNumber)
  3. getDayName()
  4. getDayName(int i)
  5. getDayName(String code)
  6. getDayOfWeekName(int dayOfWeek)