private int getSelectedIndex() {
    if (date == null)
      return -1;
    Calendar bc = getCalendar(baseDate);
    Calendar sc = getCalendar(date);
    // selected date visible in base month
    if (bc.get(Calendar.ERA) == sc.get(Calendar.ERA)
        && bc.get(Calendar.YEAR) == sc.get(Calendar.YEAR)
        && bc.get(Calendar.MONTH) == sc.get(Calendar.MONTH)) {
      bc.set(Calendar.DAY_OF_MONTH, 1);
      int skipBefore = bc.get(Calendar.DAY_OF_WEEK)
          - bc.getFirstDayOfWeek();
      if (skipBefore < 0)
        skipBefore = 7 + skipBefore;
      int selDay = sc.get(Calendar.DAY_OF_MONTH);
      return skipBefore + selDay - 1;
    } else
      return -1;
  }
private int getSelectedIndex()