get Day Of Week from int - Java java.util

Java examples for java.util:Week

Description

get Day Of Week from int

Demo Code

/**/*w w  w  . ja v  a2  s.  co m*/
 * Java
 *
 * Copyright 2014 IS2T. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be found at http://www.is2t.com/open-source-bsd-license/.
 */
//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int dayOfWeek = 2;
        System.out.println(getDayOfWeek(dayOfWeek));
    }

    private static final String[] DAYS_OF_WEEK = new String[] { "Sunday",
            "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
            "Saturday" };

    public static String getDayOfWeek(int dayOfWeek) {
        return DAYS_OF_WEEK[dayOfWeek - 1];
    }
}

Related Tutorials