Java Day Name dayName(String dayNumber)

Here you can find the source of dayName(String dayNumber)

Description

Convert day from number to name

License

Open Source License

Parameter

Parameter Description
dayNumber a parameter

Declaration

public static String dayName(String dayNumber) 

Method Source Code

//package com.java2s;
/**/*from w  w w .jav a 2s . co m*/
 * Copyright (c) 2010-2018, openHAB.org and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Convert day from number to name
     *
     * @param dayNumber
     * @return
     */
    public static String dayName(String dayNumber) {
        String dayName = null;
        switch (Integer.parseInt(dayNumber)) {
        case (0):
            dayName = "Sunday";
            break;
        case (1):
            dayName = "Monday";
            break;
        case (2):
            dayName = "Tuesday";
            break;
        case (3):
            dayName = "Wednesday";
            break;
        case (4):
            dayName = "Thursday";
            break;
        case (5):
            dayName = "Friday";
            break;
        case (6):
            dayName = "Saturday";
            break;
        default:
            dayName = "Invalid day number [" + dayNumber + "]";
        }
        return (dayName);
    }
}

Related

  1. dayName(String dayNumber)
  2. getCurrentDayName()
  3. getDayName()
  4. getDayName(int i)