If you think the Android project Go2-Rennes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com
* /*fromwww.java2s.com*/
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/package fr.gotorennes.util;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import android.text.format.DateFormat;
publicclass JoursUtils {
privatestatic List<String> feries = new ArrayList<String>();
static {
feries.add("21042014");
feries.add("01052014");
feries.add("08052014");
feries.add("29052014");
feries.add("08062014");
feries.add("09062014");
feries.add("14072014");
feries.add("15082014");
feries.add("01112014");
feries.add("11112014");
feries.add("25122014");
feries.add("01012015");
feries.add("06042015");
feries.add("01052015");
feries.add("08052015");
feries.add("14052015");
feries.add("24052015");
feries.add("25052015");
feries.add("14072015");
feries.add("15082015");
feries.add("01112015");
feries.add("11112015");
feries.add("25122015");
}
publicstaticboolean isJourFerie(Calendar calendar) {
String date = DateFormat.format("ddMMyyyy", calendar.getTime()).toString();
return feries.contains(date);
}
publicstaticboolean is1erMai(Calendar calendar) {
return calendar.get(Calendar.MONTH) == Calendar.MAY && calendar.get(Calendar.DATE) == 1;
}
publicstatic String getCalendrier(boolean nuit) {
return getCalendrier(Calendar.getInstance(), nuit);
}
publicstatic String getCalendrier(Calendar calendar, boolean nuit) {
Calendar fakeCalendar = Calendar.getInstance();
fakeCalendar.setTimeInMillis(calendar.getTimeInMillis());
int heures = fakeCalendar.get(Calendar.HOUR_OF_DAY);
if (!nuit && heures < 4) {
fakeCalendar.add(Calendar.DATE, -1);
}
if (is1erMai(fakeCalendar)) {
return"0";
}
if (isJourFerie(fakeCalendar)) {
return"64";
}
switch (fakeCalendar.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY:
return"1";
case Calendar.TUESDAY:
return"2";
case Calendar.WEDNESDAY:
return"4";
case Calendar.THURSDAY:
return"8";
case Calendar.FRIDAY:
return"16";
case Calendar.SATURDAY:
return"32";
case Calendar.SUNDAY:
return"64";
}
return"0";
}
}