Java Day Convert To day2String(int dayofweek)

Here you can find the source of day2String(int dayofweek)

Description

Examine an int and determine if it is a day of the week.

License

Open Source License

Parameter

Parameter Description
dayofweek A given day of the week as an int.

Return

An String value representing the day of the week.

Declaration

public static String day2String(int dayofweek) 

Method Source Code

//package com.java2s;
/*//w  w  w  .j av  a 2  s  .com
This file is part of JFLICKS.
    
JFLICKS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
JFLICKS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with JFLICKS.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    /**
     * Examine an int and determine if it is a day of the week.  If so then
     * return a String value where 1 = Sunday, 2 = Monday, etc.
     *
     * @param dayofweek A given day of the week as an int.
     * @return An String value representing the day of the week.
     */
    public static String day2String(int dayofweek) {

        String result = "Sunday";

        if (dayofweek == 1) {
            result = "Sunday";
        } else if (dayofweek == 2) {
            result = "Monday";
        } else if (dayofweek == 3) {
            result = "Tuesday";
        } else if (dayofweek == 4) {
            result = "Wednesday";
        } else if (dayofweek == 5) {
            result = "Thursday";
        } else if (dayofweek == 6) {
            result = "Friday";
        } else if (dayofweek == 7) {
            result = "Saturday";
        }

        return (result);
    }
}

Related

  1. day2doy(int year, int month, int mday)
  2. day2msec(int day)
  3. daysToSecs(long days)
  4. daysToTicks(double x)
  5. daysToYears(int days)