Java Week Day getWeekendDays(Locale locale)

Here you can find the source of getWeekendDays(Locale locale)

Description

get Weekend Days

License

Open Source License

Declaration

private static int[] getWeekendDays(Locale locale) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2015 BSI Business Systems Integration AG.
 * 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
 *
 * Contributors:/*from w ww  .  j a v  a2s . co  m*/
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.util.Arrays;
import java.util.Calendar;

import java.util.List;
import java.util.Locale;

public class Main {
    private static final List<String> SUN_WEEKEND_DAYS_COUNTRIES = Arrays
            .asList(new String[] { "GQ", "IN", "TH", "UG" });
    private static final List<String> FRY_WEEKEND_DAYS_COUNTRIES = Arrays.asList(new String[] { "DJ", "IR" });
    private static final List<String> FRY_SUN_WEEKEND_DAYS_COUNTRIES = Arrays.asList(new String[] { "BN" });
    private static final List<String> THU_FRY_WEEKEND_DAYS_COUNTRIES = Arrays.asList(new String[] { "AF" });
    private static final List<String> FRY_SAT_WEEKEND_DAYS_COUNTRIES = Arrays.asList(new String[] { "AE", "DZ",
            "BH", "BD", "EG", "IQ", "IL", "JO", "KW", "LY", "MV", "MR", "OM", "PS", "QA", "SA", "SD", "SY", "YE" });

    private static int[] getWeekendDays(Locale locale) {
        if (THU_FRY_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) {
            return new int[] { Calendar.THURSDAY, Calendar.FRIDAY };
        } else if (FRY_SUN_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) {
            return new int[] { Calendar.FRIDAY, Calendar.SUNDAY };
        } else if (FRY_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) {
            return new int[] { Calendar.FRIDAY };
        } else if (SUN_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) {
            return new int[] { Calendar.SUNDAY };
        } else if (FRY_SAT_WEEKEND_DAYS_COUNTRIES.contains(locale.getCountry())) {
            return new int[] { Calendar.FRIDAY, Calendar.SATURDAY };
        } else {
            return new int[] { Calendar.SATURDAY, Calendar.SUNDAY };
        }
    }
}

Related

  1. getWeekdayNames(Locale locale)
  2. getWeekDayNUM()
  3. getWeekdayOfDateTime(String datetime)
  4. getWeekdays(DateFormatSymbols symbols)
  5. getWeekDayStr(int dayInWeek)
  6. getWeekFirstDay(Date date)
  7. isDayOfWeek(int day)
  8. isDayOfWeek(String str, int dayOfWeek)
  9. isFirseDayOfCurrentWeek(Date date)