Android examples for java.util:Month
get Month Offset as int value
//package com.java2s; import java.util.Calendar; public class Main { /**/*from ww w . j a va 2 s. c om*/ * * @param currentCalendar * @param firstDayOfWeek * @return */ public static int getMonthOffset(Calendar currentCalendar, int firstDayOfWeek) { final Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(firstDayOfWeek); calendar.setTime(currentCalendar.getTime()); calendar.set(Calendar.DAY_OF_MONTH, 1); int firstDayWeekPosition = calendar.getFirstDayOfWeek(); int dayPosition = calendar.get(Calendar.DAY_OF_WEEK); if (firstDayWeekPosition == 1) { return dayPosition - 1; } else { if (dayPosition == 1) { return 6; } else { return dayPosition - 2; } } } }