Here you can find the source of dayOfWeekFromInt(final int theDay)
Parameter | Description |
---|---|
theDay | an integer between 1 and 7 denoting the day of the week. 1 being Sunday. |
Parameter | Description |
---|---|
IllegalArgumentException | if argument theDay is not in range of 1 to 7 |
public static String dayOfWeekFromInt(final int theDay) throws IllegalArgumentException
//package com.java2s; /*//from w w w . jav a2 s . c o m * #%L * org.bml * %% * Copyright (C) 2006 - 2014 Brian M. Lima * %% * This file is part of ORG.BML. * * ORG.BML 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. * * ORG.BML 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with ORG.BML. If not, see <http://www.gnu.org/licenses/>. * #L% */ public class Main { /** * Conversion utility for getting a print friendly string representation of * a day of the week from a numeric between 1 and 7. Sunday is 1. * * @param theDay an integer between 1 and 7 denoting the day of the week. 1 * being Sunday. * @return a print friendly string representation of a day of the week. 1 * being Sunday. * @throws IllegalArgumentException if argument theDay is not in range of 1 to 7 */ public static String dayOfWeekFromInt(final int theDay) throws IllegalArgumentException { if (theDay > 7 || theDay < 1) { throw new IllegalArgumentException("Argument theDay is not in range of 1 to 7"); } switch (theDay) { case 1: return "Sunday"; case 2: return "Monday"; case 3: return "Tuesday"; case 4: return "Wednesday"; case 5: return "Thursday"; case 6: return "Friday"; case 7: return "Saturday"; default: //unreachable but the compiler wants it! return null; } } }