Android Date Interval Get getDateOffset()

Here you can find the source of getDateOffset()

Description

get Date Offset

License

Open Source License

Declaration

public static int getDateOffset() 

Method Source Code

//package com.java2s;
/*/*w  w w .  j  a  v a  2  s  .  co m*/
 * SBHS-Timetable-Android: Countdown and timetable all at once (Android app).
 * Copyright (C) 2014 Simon Shields, James Ye
 *
 * This file is part of SBHS-Timetable-Android.
 *
 * 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, or
 * (at your option) any later version.
 *
 * 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/>.
 */

import java.util.Calendar;

public class Main {
    public static int getDateOffset() { // TODO holidays - these work when done
        int day = getDay();
        int hour = getHour();
        int minute = getMinute();
        int offset = 0;
        if (day == Calendar.SATURDAY) {
            // push to sunday afternoon.
            offset++;
        } else if (day == Calendar.FRIDAY
                && (hour > 15 || hour == 15 && minute >= 15)) {
            offset += 2;
        }
        return offset;
    }

    public static int getDay() {
        return cal().get(Calendar.DAY_OF_WEEK);
    }

    public static int getHour() {
        return cal().get(Calendar.HOUR_OF_DAY);
    }

    public static int getMinute() {
        return cal().get(Calendar.MINUTE);
    }

    private static Calendar cal() {
        return Calendar.getInstance();
    }
}

Related

  1. offsetSecond(Date date, int offset)
  2. secondBetweenDate(Date date1, Date date2)
  3. secondDiff(Date date1, Date date2)
  4. secondDiff(String startTime, String endTime)
  5. secondsBetween(Date dt1, Date dt2)
  6. interval(Date date)
  7. checkIsIntervalDay(String startTime, String endTime)
  8. totalDays(Object o)
  9. calculatorDaysAgo(String date, Locale locale, String format)