Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DateFormatSymbols;

public class Main {
    /** ExpCalendarUtil.java
     * The number to Week
     * @param number - Number day of Week (on the code Sunday is equal 7)
     * @return [String] - abbreviated name of the days of the week
     */
    public static String number2Week(int number) {
        if (number < 1 || number > 7)
            return null; //Day of Week 1-7
        if (number == 7) {
            number = 1;
        } else {
            number = number + 1;
        }
        final DateFormatSymbols symbols = new DateFormatSymbols(); //use user locale
        final String nameDayOfWeek = symbols.getShortWeekdays()[number]; //Short name or getWeekdays for complete name
        return nameDayOfWeek.toUpperCase(); //name to uppercase
    }
}