Example usage for org.joda.time LocalDate now

List of usage examples for org.joda.time LocalDate now

Introduction

In this page you can find the example usage for org.joda.time LocalDate now.

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:es.usc.citius.servando.calendula.persistence.Schedule.java

License:Open Source License

public DateTime startDateTime() {
    LocalDate s = start != null ? start : LocalDate.now();
    LocalTime t = startTime != null ? startTime : LocalTime.MIDNIGHT;
    return s.toDateTime(t);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmIntentParams.java

License:Open Source License

public DateTime dateTime() {
    if (!TextUtils.isEmpty(date) && !TextUtils.isEmpty(scheduleTime))
        return date().toDateTime(scheduleTime());
    else if (!TextUtils.isEmpty(date))
        return date().toDateTimeAtStartOfDay();
    else if (!TextUtils.isEmpty(scheduleTime))
        return LocalDate.now().toDateTime(scheduleTime());

    return null;//from  w  ww .  j a  v  a 2  s . c  o m
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public void updateAllAlarms(Context ctx) {
    for (Schedule schedule : Schedule.findAll()) {
        setAlarmsIfNeeded(schedule, LocalDate.now(), ctx);
    }
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public void onCreateOrUpdateRoutine(Routine r, Context ctx) {
    Log.d(TAG, "onCreateOrUpdateRoutine: " + r.getId() + ", " + r.name());
    setFirstAlarm(r, LocalDate.now(), ctx);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public void onCreateOrUpdateSchedule(Schedule s, Context ctx) {
    Log.d(TAG, "onCreateOrUpdateSchedule: " + s.getId() + ", " + s.medicine().name());
    setAlarmsIfNeeded(s, LocalDate.now(), ctx);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public void onDeleteRoutine(Routine r, Context ctx) {
    Log.d(TAG, "onDeleteRoutine: " + r.getId() + ", " + r.name());
    cancelAlarm(r, LocalDate.now(), ctx);
}

From source file:es.usc.citius.servando.calendula.scheduling.DailyAgenda.java

License:Open Source License

public void addItem(Patient p, ScheduleItem item, boolean taken) {
    // add to daily schedule
    DailyScheduleItem dsi;/*from w w  w. j a va  2 s. c  om*/
    if (item.schedule().enabledForDate(LocalDate.now())) {
        dsi = new DailyScheduleItem(item);
        dsi.setPatient(p);
        dsi.setTakenToday(taken);
        dsi.save();
    }

    for (int i = 1; i <= NEXT_DAYS_TO_SHOW; i++) {
        LocalDate date = LocalDate.now().plusDays(i);
        if (item.schedule().enabledForDate(date)) {
            dsi = new DailyScheduleItem(item);
            dsi.setDate(LocalDate.now().plusDays(i));
            dsi.setTakenToday(taken);
            dsi.setPatient(p);
            dsi.save();
        }
    }
}

From source file:es.usc.citius.servando.calendula.scheduling.DailyAgenda.java

License:Open Source License

public void addItem(Patient p, Schedule s, LocalTime time) {
    // add to daily schedule
    DailyScheduleItem dsi;//w w w.  ja va  2 s. co  m
    if (s.enabledForDate(LocalDate.now())) {
        dsi = new DailyScheduleItem(s, time);
        dsi.setPatient(p);
        dsi.save();
    }
    for (int i = 1; i <= NEXT_DAYS_TO_SHOW; i++) {
        LocalDate date = LocalDate.now().plusDays(i);
        if (s.enabledForDate(date)) {
            dsi = new DailyScheduleItem(s, time);
            dsi.setPatient(p);
            dsi.setDate(date);
            dsi.save();
        }
    }
}

From source file:es.usc.citius.servando.calendula.scheduling.NotificationEventReceiver.java

License:Open Source License

@Override
public void onReceive(Context context, Intent intent) {

    long routineId;
    long scheduleId;
    String scheduleTime;/*from   w  ww.ja  v  a2s .c  om*/
    LocalDate date;

    int action = intent.getIntExtra(CalendulaApp.INTENT_EXTRA_ACTION, -1);

    Log.d(TAG, "Notification event received - Action : " + action);

    String dateStr = intent.getStringExtra("date");
    if (dateStr != null) {
        date = DateTimeFormat.forPattern(AlarmIntentParams.DATE_FORMAT).parseLocalDate(dateStr);
    } else {
        Log.w(TAG, "Date not supplied, assuming today.");
        date = LocalDate.now();
    }

    switch (action) {

    case CalendulaApp.ACTION_CANCEL_ROUTINE:
        routineId = intent.getLongExtra(CalendulaApp.INTENT_EXTRA_ROUTINE_ID, -1);
        if (routineId != -1) {
            AlarmScheduler.instance().onIntakeCancelled(Routine.findById(routineId), date, context);
            Toast.makeText(context, context.getString(R.string.reminder_cancelled_message), Toast.LENGTH_SHORT)
                    .show();
        }
        break;

    case CalendulaApp.ACTION_CANCEL_HOURLY_SCHEDULE:
        scheduleId = intent.getLongExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_ID, -1);
        scheduleTime = intent.getStringExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_TIME);
        if (scheduleId != -1 && scheduleTime != null) {
            LocalTime t = DateTimeFormat.forPattern("kk:mm").parseLocalTime(scheduleTime);
            AlarmScheduler.instance().onIntakeCancelled(Schedule.findById(scheduleId), t, date, context);
            Toast.makeText(context, context.getString(R.string.reminder_cancelled_message), Toast.LENGTH_SHORT)
                    .show();
        }
        break;

    default:
        Log.d(TAG, "Request not handled " + intent.toString());
        break;
    }

}

From source file:es.usc.citius.servando.calendula.util.PickupUtils.java

License:Open Source License

/**
 * Get urgent meds, that are meds we can take within a margin of one or two days
 * before the next intake is delayed//from   www .j  av a 2 s  . c  o m
 * @return
 */
public List<PickupInfo> urgentMeds() {
    if (urgentMeds == null) {
        urgentMeds = new ArrayList<>();
        LocalDate now = LocalDate.now();
        for (PickupInfo p : pickups) {
            if (!p.taken() && p.to().isAfter(now) && p.from().plusDays(MAX_DAYS - 3).isBefore(now)) {
                urgentMeds.add(p);
            }
        }
    }
    return urgentMeds;
}