private String getSelectedDatesString() {
   CalendarDay date = calendarView.getSelectedDate();
   if (date == null) {
     return FORMATTER.format(new Date());
   }
   return FORMATTER.format(date.getDate());
 }
  private void initializeCalendar() {

    calendario.setOnDateChangedListener(listener);
    calendario.setShowOtherDates(MaterialCalendarView.SHOW_ALL);

    Calendar calendar = Calendar.getInstance();
    calendario.setSelectedDate(calendar.getTime());

    /*calendar.set(calendar.get(Calendar.YEAR), Calendar.JANUARY, 1);
    calendario.setMinimumDate(calendar.getTime());

    calendar.set(calendar.get(Calendar.YEAR), Calendar.DECEMBER, 31);
    calendario.setMaximumDate(calendar.getTime());*/

    calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -2);

    OneDayDecorator diaDecor = new OneDayDecorator();

    ArrayList<CalendarDay> dates = new ArrayList<>();
    CalendarDay cal = CalendarDay.from(calendar);

    dates.add(cal);

    // calendario.addDecorator(new EventDecorator(0xffcccccc, dates));
    diaDecor.setDate(new Date(calendar.getTimeInMillis()));
    calendario.addDecorator(diaDecor);
  }
 @Override
 public void onDateSelected(@NonNull MaterialCalendarView widget, @Nullable CalendarDay date) {
   if (date == null) {
     textView.setText(null);
   } else {
     textView.setText(FORMATTER.format(date.getDate()));
   }
 }
  public static void refreshNote(CalendarDay calendarDay) {
    date = String.valueOf(formatter.format(calendarDay.getDate()));

    add_note.setVisibility(View.VISIBLE);
    sched_title.setVisibility(View.VISIBLE);
    sched_details.setVisibility(View.GONE);
    note_edit_delete.setVisibility(View.GONE);

    if (GuideProfileFragment.notes.size() > 0) {
      note = getNoteByDate(date);
      if (note != null) {
        add_note.setVisibility(View.GONE);
        note_edit_delete.setVisibility(View.VISIBLE);
        sched_details.setVisibility(View.VISIBLE);

        sched_title.setText(note.note_title);
        sched_details.setText(note.note_detail);

        edit_note.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                showAlertDialog("Edit Note", "edit");
              }
            });

        delete_note.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setIcon(R.drawable.guia_dialog);
                builder.setTitle("Warning!");
                builder.setMessage("\nAre you sure you want to delete note?\n");
                builder.setNegativeButton("No", null);
                builder.setPositiveButton(
                    "Yes",
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        JSONParser.getInstance(context)
                            .deleteNote(Constants.deleteNote + note.note_id);
                      }
                    });
                builder.show();
              }
            });
      } else {
        sched_title.setText("Nothing to do " + date);
      }
    } else {
      sched_title.setText("Nothing to do " + date);
    }

    calendar.removeDecorators();
    markDates();
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    dialogOpened = false;

    if (resultCode != Activity.RESULT_OK) {
      return;
    }

    switch (requestCode) {
      case DatePickerDialog.FROM_DATE_PICKED:
        CalendarDay day = data.getParcelableExtra("date");
        fromDate.setText(EnvUtil.getFormattedDate(day.getDate().getTime()));
        break;
      case DatePickerDialog.TO_DATE_PICKED:
        day = data.getParcelableExtra("date");
        toDate.setText(EnvUtil.getFormattedDate(day.getDate().getTime()));
        break;
    }

    updateData();
  }
    @Override
    protected List<CalendarDay> doInBackground(@NonNull Void... voids) {
      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      Calendar calendar = Calendar.getInstance();
      calendar.add(Calendar.MONTH, 0);
      ArrayList<CalendarDay> dates = new ArrayList<>();

      CalendarDay day = CalendarDay.from(calendar);
      dates.add(day);
      //            calendar.add(Calendar.DATE, 5);

      return dates;
    }
 /** {@inheritDoc} */
 @Override
 public @NonNull String format(@NonNull CalendarDay day) {
   return dateFormat.format(day.getDate());
 }
 /**
  * We're changing the internals, so make sure to call {@linkplain
  * MaterialCalendarView#invalidateDecorators()}
  */
 public void setDate(Date date) {
   this.date = CalendarDay.from(date);
 }
 @Override
 public boolean shouldDecorate(CalendarDay day) {
   return date != null && day.equals(date);
 }
 public OneDayDecorator() {
   date = CalendarDay.today();
 }
 @Override
 public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
   Toast.makeText(this, FORMATTER.format(date.getDate()), Toast.LENGTH_SHORT).show();
 }
 @Override
 public void onMonthChanged(MaterialCalendarView materialCalendarView, CalendarDay calendarDay) {
   Toast.makeText(
           getApplicationContext(), FORMATTER.format(calendarDay.getDate()), Toast.LENGTH_SHORT)
       .show();
 }
 private void setTotal() {
   CalendarDay date = calendarView.getSelectedDate();
   promise_date = new SimpleDateFormat("yyMMdd").format(date.getDate()).toString();
   total = promise_date + promise_time; /* format : '%y%m%d%I%i' */
 }