Example usage for org.joda.time DateTime toLocalDate

List of usage examples for org.joda.time DateTime toLocalDate

Introduction

In this page you can find the example usage for org.joda.time DateTime toLocalDate.

Prototype

public LocalDate toLocalDate() 

Source Link

Document

Converts this object to a LocalDate with the same date and chronology.

Usage

From source file:com.index.IndexServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*w w  w  . j  av a 2 s.  c om*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    if (request.getParameter("startdate") == null && request.getParameter("enddate") == null) {
        DateTime now = new DateTime();
        LocalDate today = now.toLocalDate();
        LocalDate tomorrow = today.plusDays(1);
        IndexData data = new IndexData(today.minusDays(7).toString(), tomorrow.toString(), "leadSession",
                request.getContextPath());
        request.setAttribute("mostlyVisited", data.getMostlyVisited());
        request.setAttribute("totalSessionCount", data.getTotalSessionCount());
        request.setAttribute("totalAddressCount", data.getTotalAddressCount());
        request.setAttribute("companyLinks", data.getCompanyLinks());
        request.setAttribute("contacts", data.getContacts());
    }
    if (request.getParameter("startdate") != null && request.getParameter("enddate") != null) {
        IndexData data = new IndexData(request.getParameter("startdate"), request.getParameter("enddate"),
                "leadSession", request.getContextPath());
        request.setAttribute("mostlyVisited", data.getMostlyVisited());
        request.setAttribute("totalSessionCount", data.getTotalSessionCount());
        request.setAttribute("totalAddressCount", data.getTotalAddressCount());
        request.setAttribute("companyLinks", data.getCompanyLinks());
        request.setAttribute("contacts", data.getContacts());
    }
    request.getRequestDispatcher("/index.jsp").forward(request, response);
}

From source file:com.jay.pea.mhealthapp2.model.MedicationManager.java

License:Open Source License

/**
 * Method to build the first dose map which holds the dose due time and the dose taken time.
 * If not taken the dose taken time is recorded as epoch 01-01-70.
 *
 * @param med//from   w  w w  .  jav  a 2 s.  co m
 * @param context
 * @return
 */
public HashMap<DateTime, DateTime> buildDoseMap1(Medication med, Context context) {
    //get a db object
    dbOpenHelper = new MedDBOpenHelper(context);

    //get final med
    final Medication medication = med;

    //hash map to map doses to taken bool
    HashMap<DateTime, DateTime> doseMap1 = new HashMap();

    //get existing hashMap details if exist
    doseMap1 = dbOpenHelper.getDoseMaps(medication)[0];

    //erase all future dose data, retain past data

    //get inclusive start and end date
    DateTime startDate = new DateTime(med.getMedStart() * 1000l);
    DateTime endDate = new DateTime(med.getMedEnd() * 1000l);

    //set hashStart date as today
    DateTime hashStart = today;

    //if medication is in future set hashStart to future date, if med start is in the past, set hashStart to today (for update to HashMap)
    if (hashStart.isBefore(startDate))
        hashStart = startDate;

    //get alarm times
    DateTime alert1 = new DateTime(med.getAlert1() * 1000l);
    DateTime alert2 = new DateTime(med.getAlert2() * 1000l);
    DateTime alert3 = new DateTime(med.getAlert3() * 1000l);
    DateTime alert4 = new DateTime(med.getAlert4() * 1000l);
    DateTime alert5 = new DateTime(med.getAlert5() * 1000l);
    DateTime alert6 = new DateTime(med.getAlert6() * 1000l);

    DateTime[] dtArray = new DateTime[] { alert1, alert2, alert3, alert4, alert5, alert6 };

    //get the number of days of med prescription
    int days = Days.daysBetween(hashStart.toLocalDate(), endDate.toLocalDate()).getDays() + 1;

    //get Frequency for alerts to ignore non required alerts.
    int freq = med.getFreq();

    //build the hashmap for daily dose due dates and bool for taken, if in the past exclude the reminder
    for (int i = 0; i < days; i++) {
        DateTime thisDay = hashStart.plusDays(i);
        //for the freq setup all alerts
        for (int j = 0; j < freq; j++) {
            DateTime alertTime = thisDay.withHourOfDay(dtArray[j].getHourOfDay())
                    .withMinuteOfHour(dtArray[j].getMinuteOfHour()).withSecondOfMinute(0);
            final DateTime zeroDate = new DateTime(0);
            doseMap1.put(alertTime, zeroDate);
            Log.d(TAG, alertTime + " Time" + dtArray[j].getHourOfDay() + " zero date  " + zeroDate);
        }

    }
    //get existing hashMap details if exist
    HashMap<DateTime, DateTime> tempDoseMap1 = dbOpenHelper.getDoseMaps(medication)[0];

    //add all past dose data,
    if (!tempDoseMap1.isEmpty()) {
        for (DateTime dateTime : tempDoseMap1.keySet()) {

            if (dateTime.isBefore(today)) {
                doseMap1.put(dateTime, tempDoseMap1.get(dateTime));
            }
        }
    }
    Log.d(TAG, doseMap1.size() + " doseMap1 size");
    return doseMap1;
}

From source file:com.jay.pea.mhealthapp2.model.MedicationManager.java

License:Open Source License

/**
 * Method to build the second dose map which holds the dose due time and an int for if an alert
 * has been set.//from  w w w  . j av a  2 s  .  c om
 *
 * @param med
 * @param context
 * @return
 */
public HashMap<DateTime, Integer> buildDoseMap2(Medication med, Context context) {

    //get a db object
    dbOpenHelper = new MedDBOpenHelper(context);

    //get final med
    final Medication medication = med;

    //hash map to map doses to taken bool
    HashMap<DateTime, Integer> doseMap2 = new HashMap();

    //set hashStart date as today
    DateTime hashStart = today;

    //get inclusive start and end date
    DateTime startDate = new DateTime(med.getMedStart() * 1000l);
    DateTime endDate = new DateTime(med.getMedEnd() * 1000l);

    //if medication is in future set hashStart to future date, if med start is in the past, set hashStart to today (for update to HashMap)
    if (hashStart.isBefore(startDate))
        hashStart = startDate;

    //get alarm times
    DateTime alert1 = new DateTime(med.getAlert1() * 1000l);
    DateTime alert2 = new DateTime(med.getAlert2() * 1000l);
    DateTime alert3 = new DateTime(med.getAlert3() * 1000l);
    DateTime alert4 = new DateTime(med.getAlert4() * 1000l);
    DateTime alert5 = new DateTime(med.getAlert5() * 1000l);
    DateTime alert6 = new DateTime(med.getAlert6() * 1000l);

    DateTime[] dtArray = new DateTime[] { alert1, alert2, alert3, alert4, alert5, alert6 };
    Log.d(TAG, Arrays.toString(dtArray));

    //get the number of days of med prescription
    int days = Days.daysBetween(hashStart.toLocalDate(), endDate.toLocalDate()).getDays() + 1;

    //get Frequency for alerts to ignore non required alerts.
    int freq = med.getFreq();
    Log.d(TAG, freq + " Days =" + days + " " + med.getMedName());

    //build the hashmap for daily dose due dates and alertsOn Integer, if in the past exclude the reminder
    for (int i = 0; i < days; i++) {
        DateTime thisDay = hashStart.plusDays(i);

        //for the freq setup all alertsOn
        for (int j = 0; j < freq; j++) {
            DateTime alertTime = thisDay.withHourOfDay(dtArray[j].getHourOfDay())
                    .withMinuteOfHour(dtArray[j].getMinuteOfHour()).withSecondOfMinute(0);
            if (alertTime.isAfter(today))
                doseMap2.put(alertTime, medication.getAlertsOn());

        }
        Log.d(TAG, doseMap2.size() + " doseMap2 size");

    }

    //get existing hashMap details if exist
    HashMap<DateTime, Integer> tempDoseMap2 = dbOpenHelper.getDoseMaps(medication)[1];

    //add all past dose data,
    if (!tempDoseMap2.isEmpty()) {
        for (DateTime dateTime : tempDoseMap2.keySet()) {

            if (dateTime.isBefore(today)) {
                doseMap2.put(dateTime, tempDoseMap2.get(dateTime));
            }
        }
    }
    Log.d(TAG, doseMap2.size() + " doseMap2 size");
    return doseMap2;
}

From source file:com.jay.pea.mhealthapp2.presenter.FutureMeds.java

License:Open Source License

/**
 * method to update the listview when the data changes
 *//*from w w w.j  a v  a2 s. c om*/
private void updateListView() {

    dbHelper = new MedDBOpenHelper(this);
    medList = dbHelper.getAllMeds();
    fdal = new ArrayList<>();

    DateTime startDate = dtfDate.parseDateTime(startTV.getText().toString());
    DateTime endDate = dtfDate.parseDateTime(endTV.getText().toString());

    int diffDays = Days.daysBetween(startDate.toLocalDate(), endDate.toLocalDate()).getDays();
    if (diffDays < 0) {
        Snackbar.make(cl, "Please ensure the end date is after the start date", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show();
    } else {
        for (Medication med : medList) {
            FutureDoses fd = new FutureDoses(med.getDose(), endDate, med.getFreq(), med.getMedName(),
                    startDate);
            fdal.add(fd);
        }
        listViewAdaptorMedFut = new CustomCardViewAdaptorMedFuture(this, fdal);
        listView.setAdapter(listViewAdaptorMedFut);
    }

}

From source file:com.metinkale.prayerapp.vakit.times.Times.java

License:Apache License

@NonNull
private Collection<Alarm> getAlarms() {
    Collection<Alarm> alarms = new ArrayList<>();

    LocalDate cal = LocalDate.now();
    for (int ii = 0; ii <= 1/* next day */; ii++) {
        for (Vakit v : Vakit.values()) {
            if (isNotificationActive(v)) {
                if (v != Vakit.SABAH) {
                    int vakit = v.ordinal();
                    if (vakit != 0) {
                        vakit--;/*from www  .  j a va 2 s  .  c o m*/
                    }

                    long mills = getTimeCal(cal, vakit).toDateTime().getMillis();
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.early = false;
                        a.cuma = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                } else {
                    long mills;
                    if (isAfterImsak()) {
                        mills = getTimeCal(cal, 0).toDateTime().getMillis() + getSabahTime() * 60 * 1000;
                    } else {
                        mills = getTimeCal(cal, 1).toDateTime().getMillis() - getSabahTime() * 60 * 1000;
                    }
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.cuma = false;
                        a.early = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                }
            }

            if (isEarlyNotificationActive(v)) {
                if (v != Vakit.SABAH) {
                    int vakit = v.ordinal();
                    if (vakit != 0) {
                        vakit--;
                    }

                    int early = getEarlyTime(v);
                    long mills = getTimeCal(cal, vakit).toDateTime().getMillis() - early * 60 * 1000;
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.early = true;
                        a.cuma = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                }
            }
        }
        cal = cal.plusDays(1);
    }
    if (isCumaActive()) {

        int early = getCumaTime();

        DateTime c = DateTime.now().withDayOfWeek(DateTimeConstants.FRIDAY);
        if ((c.getMillis() + 1000) < System.currentTimeMillis()) {
            c = c.plusWeeks(1);
        }
        long mills = getTimeCal(c.toLocalDate(), 2).toDateTime().getMillis();
        mills -= early * 60 * 1000;
        if (System.currentTimeMillis() < mills) {
            Alarm a = new Alarm();
            a.city = getID();
            a.cuma = true;
            a.early = false;
            a.time = mills;
            a.vakit = Vakit.OGLE;
            a.dayOffset = 0;
            alarms.add(a);
        }
    }

    return alarms;
}

From source file:com.mycollab.module.project.view.task.TaskEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(final Object propertyId) {
    if (Task.Field.assignuser.equalTo(propertyId)) {
        ProjectMemberSelectionField field = new ProjectMemberSelectionField();
        field.addValueChangeListener(valueChangeEvent -> {
            Property property = valueChangeEvent.getProperty();
            SimpleProjectMember member = (SimpleProjectMember) property.getValue();
            if (member != null) {
                subscribersComp.addFollower(member.getUsername());
            }//from  w  ww  . j  a v a  2 s  . c  o m
        });
        return field;
    } else if (Task.Field.milestoneid.equalTo(propertyId)) {
        return new MilestoneComboBox();
    } else if (Task.Field.description.equalTo(propertyId)) {
        final RichTextArea richTextArea = new RichTextArea();
        richTextArea.setNullRepresentation("");
        return richTextArea;
    } else if (Task.Field.name.equalTo(propertyId)) {
        return new MTextField().withNullRepresentation("").withRequired(true)
                .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                        UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
    } else if (Task.Field.status.equalTo(propertyId)) {
        return new TaskStatusComboBox();
    } else if (Task.Field.percentagecomplete.equalTo(propertyId)) {
        return new TaskSliderField();
    } else if (Task.Field.priority.equalTo(propertyId)) {
        return new PriorityComboBox();
    } else if (Task.Field.duration.equalTo(propertyId)) {
        final TextField field = new TextField();
        field.setConverter(new HumanTimeConverter());
        final SimpleTask beanItem = attachForm.getBean();
        if (beanItem.getNumSubTasks() != null && beanItem.getNumSubTasks() > 0) {
            field.setEnabled(false);
            field.setDescription(UserUIContext.getMessage(TaskI18nEnum.ERROR_CAN_NOT_EDIT_PARENT_TASK_FIELD));
        }

        //calculate the end date if the start date is set
        field.addBlurListener(blurEvent -> {
            HumanTime humanTime = HumanTime.eval(field.getValue());
            long duration = Long.valueOf(humanTime.getDelta() + "");
            DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup
                    .getField(Task.Field.startdate.name());
            Date startDateVal = startDateField.getValue();
            if (duration > 0 && startDateVal != null) {
                int daysDuration = (int) (duration / DateTimeUtils.MILLISECONDS_IN_A_DAY);
                if (daysDuration > 0) {
                    DateTime startDateJoda = new DateTime(startDateVal);
                    LocalDate calculatedDate = BusinessDayTimeUtils.plusDays(startDateJoda.toLocalDate(),
                            daysDuration);
                    DateTime endDateJoda = new DateTime(calculatedDate.toDate());
                    DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup
                            .getField(Task.Field.enddate.name());
                    beanItem.setEnddate(endDateJoda.toDate());
                    endDateField.setPropertyDataSource(
                            new TransactionalPropertyWrapper<>(new MethodProperty(beanItem, "enddate")));
                }
            }
        });
        return field;
    } else if (Task.Field.originalestimate.equalTo(propertyId)
            || Task.Field.remainestimate.equalTo(propertyId)) {
        return new DoubleField();
    } else if (Task.Field.startdate.equalTo(propertyId)) {
        final DateTimeOptionField startDateField = new DateTimeOptionField(true);
        startDateField.addValueChangeListener(valueChangeEvent -> calculateDurationBaseOnStartAndEndDates());
        return startDateField;
    } else if (Task.Field.enddate.equalTo(propertyId)) {
        DateTimeOptionField endDateField = new DateTimeOptionField(true);
        endDateField.addValueChangeListener(valueChangeEvent -> calculateDurationBaseOnStartAndEndDates());
        return endDateField;
    } else if (Task.Field.id.equalTo(propertyId)) {
        Task beanItem = attachForm.getBean();
        if (beanItem.getId() != null) {
            String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(),
                    beanItem.getProjectid(), ProjectTypeConstants.TASK, "" + beanItem.getId());
            attachmentUploadField = new AttachmentUploadField(attachmentPath);
        } else {
            attachmentUploadField = new AttachmentUploadField();
        }
        return attachmentUploadField;
    } else if (Task.Field.duedate.equalTo(propertyId)) {
        return new DateTimeOptionField(true);
    } else if (propertyId.equals("selected")) {
        return subscribersComp;
    }
    return null;
}

From source file:com.ning.killbill.zuora.zuora.ZuoraApi.java

License:Apache License

public Either<ZuoraError, List<Invoice>> getInvoicesForAccount(final ZuoraConnection connection,
        final Account account, @Nullable final DateTime from, @Nullable final DateTime to) {
    // We need to round down the to, invoice date in Zuora is in the form 2011-09-29T00:00:00.000-08:00
    final String toDate = to == null ? ""
            : to.toLocalDate().toDateTimeAtStartOfDay(DateTimeZone.forID("Pacific/Pitcairn")).toString();

    final String query;
    if (from == null && to != null) {
        query = stringTemplateLoader.load("getPostedInvoicesForAccountTo").define("accountId", account.getId())
                .define("invoiceDateTo", toDate).build();
    } else if (from != null && to != null) {
        query = stringTemplateLoader.load("getPostedInvoicesForAccountFromTo")
                .define("accountId", account.getId()).define("invoiceDateTo", toDate)
                .define("invoiceDateFrom", from.toString()).build();
    } else {//  w w  w  .ja va  2  s. c  o m
        throw new UnsupportedOperationException();
    }

    final Either<ZuoraError, List<Invoice>> invoicesOrError = connection.query(query);
    if (invoicesOrError.isLeft()) {
        return Either.left(invoicesOrError.getLeft());
    } else {
        return Either.right(invoicesOrError.getRight());
    }
}

From source file:com.ofalvai.bpinfo.util.UiUtils.java

License:Apache License

/**
 * Transforms the start and end timestamps into a human-friendly readable string,
 * with special replacements for special dates, times, and the API's strange notations.
 * @param context Context//from w  w w. ja v  a2 s. c om
 * @param startTimestamp Start of the alert in seconds since the UNIX epoch
 * @param endTimestamp   End of the alert in seconds since the UNIX epoch
 * @return  A string in the format of [startdate] [starttime] [separator] [enddate] [endtime]
 */
@NonNull
public static String alertDateFormatter(Context context, long startTimestamp, long endTimestamp) {
    DateTime startDateTime = new DateTime(startTimestamp * 1000L);
    DateTime endDateTime = new DateTime(endTimestamp * 1000L);
    LocalDate startDate = startDateTime.toLocalDate();
    LocalDate endDate = endDateTime.toLocalDate();

    DateTime today = new DateTime();
    LocalDate todayDate = new DateTime().toLocalDate();
    DateTime yesterday = today.minusDays(1);
    LocalDate yesterdayDate = yesterday.toLocalDate();
    DateTime tomorrow = today.plusDays(1);
    LocalDate tomorrowDate = tomorrow.toLocalDate();

    // Alert start, date part
    String startDateString;
    if (startDate.equals(todayDate)) {
        // Start day is today, replacing month and day with today string
        startDateString = context.getString(R.string.date_today) + " ";
    } else if (startDate.year().get() < today.year().get()) {
        // The start year is less than the current year, displaying the year too
        startDateString = Config.FORMATTER_DATE_YEAR.print(startDateTime);
    } else if (startDate.equals(yesterdayDate)) {
        startDateString = context.getString(R.string.date_yesterday) + " ";
    } else if (startDate.equals(tomorrowDate)) {
        startDateString = context.getString(R.string.date_tomorrow) + " ";
    } else {
        startDateString = Config.FORMATTER_DATE.print(startDateTime);
    }

    // Alert start, time part
    String startTimeString;
    if (startDateTime.hourOfDay().get() == 0 && startDateTime.minuteOfHour().get() == 0) {
        // The API marks "first departure" as 00:00
        startTimeString = context.getString(R.string.date_first_departure);
    } else {
        startTimeString = Config.FORMATTER_TIME.print(startDateTime);
    }

    // Alert end, date part
    String endDateString;
    if (endTimestamp == 0) {
        // The API marks "until further notice" as 0 (in UNIX epoch), no need to display date
        // (the replacement string is displayed as the time part, not the date)
        endDateString = " ";
    } else if (endDate.year().get() > today.year().get()) {
        // The end year is greater than the current year, displaying the year too
        endDateString = Config.FORMATTER_DATE_YEAR.print(endDateTime);
    } else if (endDate.equals(todayDate)) {
        // End  day is today, replacing month and day with today string
        endDateString = context.getString(R.string.date_today) + " ";
    } else if (endDate.equals(yesterdayDate)) {
        endDateString = context.getString(R.string.date_yesterday) + " ";
    } else if (endDate.equals(tomorrowDate)) {
        endDateString = context.getString(R.string.date_tomorrow) + " ";
    } else {
        endDateString = Config.FORMATTER_DATE.print(endDateTime);
    }

    // Alert end, time part
    String endTimeString;
    if (endTimestamp == 0) {
        // The API marks "until further notice" as 0 (in UNIX epoch)
        endTimeString = context.getString(R.string.date_until_revoke);
    } else if (endDateTime.hourOfDay().get() == 23 && endDateTime.minuteOfHour().get() == 59) {
        // The API marks "last departure" as 23:59
        endTimeString = context.getString(R.string.date_last_departure);
    } else {
        endTimeString = Config.FORMATTER_TIME.print(endDateTime);
    }

    return startDateString + startTimeString + Config.DATE_SEPARATOR + endDateString + endTimeString;
}

From source file:com.prayer.vakit.times.Times.java

License:Apache License

Collection<Alarm> getAlarms() {
    Collection<Alarm> alarms = new ArrayList<>();

    LocalDate cal = LocalDate.now();
    for (int ii = 0; ii <= 1/* next day */; ii++) {
        for (Vakit v : Vakit.values()) {
            if (isNotificationActive(v)) {
                if (v != Vakit.SABAH) {
                    int vakit = v.ordinal();
                    if (vakit != 0) {
                        vakit--;//from  w  w  w  .j  a  v  a2  s  . co  m
                    }

                    long mills = getTimeCal(cal, vakit).toDateTime().getMillis();
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.early = false;
                        a.cuma = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                } else {
                    long mills;
                    if (isAfterImsak()) {
                        mills = getTimeCal(cal, 0).toDateTime().getMillis() + getSabahTime() * 60 * 1000;
                    } else {
                        mills = getTimeCal(cal, 1).toDateTime().getMillis() - getSabahTime() * 60 * 1000;
                    }
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.cuma = false;
                        a.early = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                }
            }

            if (isEarlyNotificationActive(v)) {
                if (v != Vakit.SABAH) {
                    int vakit = v.ordinal();
                    if (vakit != 0) {
                        vakit--;
                    }

                    int early = getEarlyTime(v);
                    long mills = getTimeCal(cal, vakit).toDateTime().getMillis() - early * 60 * 1000;
                    if (System.currentTimeMillis() < mills) {
                        Alarm a = new Alarm();
                        a.city = getID();
                        a.early = true;
                        a.cuma = false;
                        a.time = mills;
                        a.vakit = v;
                        a.dayOffset = ii;
                        alarms.add(a);
                    }
                }
            }
        }
        cal = cal.plusDays(1);
    }
    if (isCumaActive()) {

        int early = getCumaTime();

        DateTime c = DateTime.now().withDayOfWeek(DateTimeConstants.FRIDAY);
        if ((c.getMillis() + 1000) < System.currentTimeMillis()) {
            c = c.plusWeeks(1);
        }
        long mills = getTimeCal(c.toLocalDate(), 2).toDateTime().getMillis();
        mills -= early * 60 * 1000;
        if (System.currentTimeMillis() < mills) {
            Alarm a = new Alarm();
            a.city = getID();
            a.cuma = true;
            a.early = false;
            a.time = mills;
            a.vakit = Vakit.OGLE;
            a.dayOffset = 0;
            alarms.add(a);
        }
    }

    return alarms;
}

From source file:com.qcadoo.mes.deviationCausesReporting.DeviationsReportCriteria.java

License:Open Source License

public static DeviationsReportCriteria forDates(final DateTime fromDate, final Optional<DateTime> maybeToDate) {
    checkArguments(fromDate, maybeToDate);
    LocalDate fromLocalDate = fromDate.toLocalDate();
    Optional<LocalDate> maybeToLocalDate = maybeToDate.transform(new Function<DateTime, LocalDate>() {

        @Override//w  w w  .j  a v a 2  s  .c o  m
        public LocalDate apply(final DateTime input) {
            return input.toLocalDate();
        }
    });
    return fromLocalDates(fromLocalDate, maybeToLocalDate);
}