Java TimeUnit Usage weekendMinutesBetween(Date date1, Date date2)

Here you can find the source of weekendMinutesBetween(Date date1, Date date2)

Description

weekend Minutes Between

License

Apache License

Declaration

public static long weekendMinutesBetween(Date date1, Date date2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class Main {
    public static long weekendMinutesBetween(Date date1, Date date2) {
        Calendar date1Calendar = Calendar.getInstance();
        date1Calendar.setTime(date1);

        long weekendMinutes = 0;
        date1Calendar.add(Calendar.DAY_OF_MONTH, 1);
        while (date2.after(date1Calendar.getTime())) {
            if (date1Calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
                    || date1Calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                weekendMinutes += TimeUnit.DAYS.toMinutes(1);
            }//from www .j a v  a  2 s .com
            date1Calendar.add(Calendar.DAY_OF_MONTH, 1);
        }
        return weekendMinutes;
    }
}

Related

  1. waitFor(Semaphore semaphore, long timeoutInMillis)
  2. waitForMinutes(long time)
  3. waitForProcess(Process process, String name)
  4. waitForResponseObject(BlockingQueue queue, Class clazz)
  5. waitForSignal(CountDownLatch b)
  6. zeroOutMs(long timestamp)

  7. HOME | Copyright © www.java2s.com 2016