get Week Index from Calendar - Android java.util

Android examples for java.util:Week

Description

get Week Index from Calendar

Demo Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    /**/*  w ww . j  a  va2s  .c o m*/
     *
     * @param weekIndex
     * @param calendar
     * @return
     */
    public static int getWeekIndex(int weekIndex, Calendar calendar) {
        int firstDayWeekPosition = calendar.getFirstDayOfWeek();
        if (firstDayWeekPosition == 1) {
            return weekIndex;
        } else {
            if (weekIndex == 1) {
                return 7;
            } else {
                return weekIndex - 1;
            }
        }
    }
}

Related Tutorials