Java Calendar Week weekFromBinStart(Calendar date)

Here you can find the source of weekFromBinStart(Calendar date)

Description

week From Bin Start

License

Apache License

Declaration

public static int weekFromBinStart(Calendar date) 

Method Source Code

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

import java.util.Calendar;

import java.util.GregorianCalendar;

public class Main {
    private static long numberOfMSInADay = 1000 * 60 * 60 * 24;
    public static Calendar startDateForBinning = new GregorianCalendar(2009, 0, 3);

    public static int weekFromBinStart(Calendar date) {

        return numberOfDaysBetween(startDateForBinning, date) / 7;
    }//from   w  w w  .j a  v  a  2 s  .co  m

    public static int numberOfDaysBetween(Calendar start, Calendar end) {

        long span = end.getTimeInMillis() - start.getTimeInMillis();
        return (int) (span / numberOfMSInADay);
    }
}

Related

  1. setStartOfWeek(Calendar date)
  2. setTimeAsFirstDayOfWeek(Calendar calendar)
  3. truncateToWeek(GregorianCalendar date)
  4. weekDay(Calendar date)
  5. weekFloor(Calendar calendar)