@SuppressLint("SimpleDateFormat")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // Must do this before super.onCreate
    ActivityHelper.readAndSetSettings(this);
    super.onCreate(savedInstanceState);

    // Intent must contain a task id
    if (getIntent() == null || getIntent().getLongExtra(Task.Columns._ID, -1) < 1) {
      setResult(RESULT_CANCELED, new Intent());
      finish();
      return;
    } else {
      mTaskID = getIntent().getLongExtra(Task.Columns._ID, -1);
    }

    timeFormatter = TimeFormatter.getLocalFormatterLong(this);
    // Default datetime format in sqlite. Set to UTC timezone
    dbTimeParser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dbTimeParser.setTimeZone(TimeZone.getTimeZone("UTC"));
  }
Example #2
0
  public String getRepeatAsText(final Context context) {
    final StringBuilder sb = new StringBuilder();

    SimpleDateFormat weekDayFormatter = TimeFormatter.getLocalFormatterWeekdayShort(context);
    // 2013-05-13 was a monday
    GregorianCalendar gc = new GregorianCalendar(2013, GregorianCalendar.MAY, 13);
    final long base = gc.getTimeInMillis();
    final long day = 24 * 60 * 60 * 1000;
    for (int i = 0; i < 7; i++) {
      gc.setTimeInMillis(base + i * day);

      if (repeatsOn(gc.get(GregorianCalendar.DAY_OF_WEEK))) {
        if (sb.length() > 0) {
          sb.append(", ");
        }
        sb.append(weekDayFormatter.format(gc.getTime()));
      }
    }

    return sb.toString();
  }
Example #3
0
 /** Returns date formatted in text in local time zone */
 public CharSequence getLocalDateText(final Context context) {
   return TimeFormatter.getDateFormatter(context).format(new Date(time));
 }
Example #4
0
 /** Returns time formatted in text in local time zone */
 public CharSequence getLocalTimeText(final Context context) {
   return TimeFormatter.getLocalTimeOnlyString(context, time);
 }