Esempio n. 1
0
 public static Recurrence noRecur() {
   Recurrence r = new Recurrence();
   r.startDate = Calendar.getInstance();
   r.pattern = RecurrencePattern.noRecur();
   r.period = RecurrencePeriod.noEndDate();
   return r;
 }
Esempio n. 2
0
 public String stateToString() {
   StringBuilder sb = new StringBuilder();
   sb.append(DateUtils.FORMAT_TIMESTAMP_ISO_8601.format(startDate.getTime())).append("~");
   sb.append(pattern.stateToString()).append("~");
   sb.append(period.stateToString());
   return sb.toString();
 }
Esempio n. 3
0
 public static Recurrence parse(String recurrence) {
   Recurrence r = new Recurrence();
   String[] a = recurrence.split("~");
   try {
     Date d = DateUtils.FORMAT_TIMESTAMP_ISO_8601.parse(a[0]);
     Calendar c = Calendar.getInstance();
     c.setTime(d);
     r.startDate = c;
   } catch (ParseException e) {
     throw new RuntimeException(recurrence);
   }
   r.pattern = RecurrencePattern.parse(a[1]);
   r.period = RecurrencePeriod.parse(a[2]);
   return r;
 }
Esempio n. 4
0
 private RRule createRRule() {
   if (pattern.frequency == RecurrenceFrequency.GEEKY) {
     try {
       HashMap<String, String> map = RecurrenceViewFactory.parseState(pattern.params);
       String rrule = map.get(RecurrenceViewFactory.P_INTERVAL);
       return new RRule("RRULE:" + rrule.toUpperCase());
     } catch (ParseException e) {
       throw new IllegalArgumentException(pattern.params);
     }
   } else {
     RRule r = new RRule();
     pattern.updateRRule(r);
     period.updateRRule(r, startDate);
     return r;
   }
 }