Code example for Calendar

Methods: addafterclearcloneset

0
    Calendar now = new GregorianCalendar();
    return alertAtAux(alertAtAbsolute(now), now);
  } 
 
  private Calendar alertAtAbsolute(Calendar now) {
    Calendar alertAt = (Calendar) now.clone();
    alertAt.set(Calendar.HOUR_OF_DAY, this.alertAt.get(Calendar.HOUR_OF_DAY));
    alertAt.set(Calendar.MINUTE, this.alertAt.get(Calendar.MINUTE));
    alertAt.clear(Calendar.SECOND);
    alertAt.clear(Calendar.MILLISECOND);
    return alertAt;
  } 
 
  private Calendar alertAtAux(Calendar alertAt, Calendar now) {
    if (isRepeating()) 
      if (repeatsFor(now))
        if (alertAt.after(now))
          return alertAt;
        else 
          return alertAtRepeating(alertAt);
      else 
        return alertAtRepeating(alertAt);
    else if (alertAt.after(now))
      return alertAt;
    else 
      return nextDay(alertAt);
  } 
 
  private boolean repeatsFor(Calendar c) {
    return repeatDays().contains(WEEKDAYS[c.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY]);
  } 
     
  private Calendar alertAtRepeating(Calendar c) {
    return alertAtRepeatingAux(nextDay(c));
  } 
   
  private Calendar alertAtRepeatingAux(Calendar c) {
    if (repeatsFor(c))
      return c;
    else 
      return alertAtRepeatingAux(nextDay(c));
  } 
   
  private Calendar nextDay(Calendar c) {
    Calendar nextC = (Calendar) c.clone();
    nextC.add(Calendar.DAY_OF_WEEK, 1);
    return nextC;
  } 
 
  public List<String> repeatDays() {
    boolean[] selections = {
Experience pair programming with AI  Get Codota for Java