Example usage for java.util Calendar after

List of usage examples for java.util Calendar after

Introduction

In this page you can find the example usage for java.util Calendar after.

Prototype

public boolean after(Object when) 

Source Link

Document

Returns whether this Calendar represents a time after the time represented by the specified Object.

Usage

From source file:freebase.api.FreebaseAPI2.java

public static void FetchingFromGoogleAPI() {

    int max_step = 1;
    int step = 0;

    int month_step = 1;
    Calendar last_date = Calendar.getInstance();
    last_date.set(Calendar.YEAR, 2016);
    last_date.set(Calendar.MONTH, 0);
    last_date.set(Calendar.DAY_OF_MONTH, 1);

    Calendar from_date = Calendar.getInstance();
    from_date.set(Calendar.YEAR, 2000);
    from_date.set(Calendar.MONTH, 0);
    from_date.set(Calendar.DAY_OF_MONTH, 1);

    Calendar to_date = (Calendar) from_date.clone();
    to_date.add(Calendar.MONTH, month_step);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    while (true) {
        //            if (step > max_step) {
        //                break;
        //            }
        //            System.out.println(">>> Cursor = " + current_cursor);
        //            if (/*films == null || films.isEmpty() ||*/step == max_step) {
        //                System.out.println("Films is null or zero size. Break.");
        //                break;
        //            }
        if (from_date.after(last_date)) {
            System.out.println("Date is after last date");
            break;
        }//from  w w  w. ja v a2  s.c o m
        String fromDate = sdf.format(from_date.getTime());
        String toDate = sdf.format(to_date.getTime());
        System.out.println(step + " ) fetch films from " + fromDate + " to " + toDate);
        step++;
        List<Film> films = getFilms(fromDate, toDate);
        System.out.println("Films#: " + films.size());
        writeToFiles(films);
        //            for (Film f : films) {
        //                System.out.println(f);
        //            }
        from_date.add(Calendar.MONTH, month_step);
        to_date.add(Calendar.MONTH, month_step);

    }
}

From source file:com.norconex.commons.lang.time.YearMonthDayInterval.java

/**
 * Gets the number of months between start and end dates, rounded down.
 * @return number of months/*  w w  w  .j a  va2s  .  c  o m*/
 */
public int getMonths() {
    int months = 0;
    Calendar cal = start.toCalendar();
    Calendar endCal = end.toCalendar();
    cal.add(Calendar.MONTH, 1);
    while (!cal.after(endCal)) {
        months++;
        cal.add(Calendar.MONTH, 1);
    }
    return months;
}

From source file:com.gsr.myschool.server.service.impl.SettingsServiceImpl.java

@Override
public void deleteDossiers(Boolean isPrepa) {
    DossierFilterDTO filter = new DossierFilterDTO();
    filter.setStatus(DossierStatus.CREATED);

    List<Dossier> dossiers = dossierService.findAllDossiersByCriteria(filter, null, null).getDossiers();

    for (Dossier dossier : dossiers) {
        // ne supprimer que les dossier cres non soumis des prepa
        Boolean skipCondition = isPrepa
                ? dossier.getFiliere() != null
                        && dossier.getFiliere().getId().longValue() < GlobalParameters.PREPA_FILIERE_FROM
                : dossier.getFiliere() != null
                        && dossier.getFiliere().getId().longValue() >= GlobalParameters.PREPA_FILIERE_FROM;
        if (skipCondition)
            continue;

        if (dossier.getCreateDate() != null) {
            Calendar date = new GregorianCalendar();
            date.setTime(dossier.getCreateDate());
            date.add(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
            Calendar deleteAfterThis = new GregorianCalendar();

            if (deleteAfterThis.after(date)) {
                try {
                    inscriptionService.deleteInscription(dossier.getId());
                } catch (Exception e) {
                    e.printStackTrace();
                }//from   w  w  w . j  a  v  a  2  s.  c  o m
            }
        }
    }
}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.PaymentDetailsValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final PaymentDetailsForm form = (PaymentDetailsForm) object;

    final Calendar start = CalendarHelper.parseDate(form.getStartMonth(), form.getStartYear());
    final Calendar expiration = CalendarHelper.parseDate(form.getExpiryMonth(), form.getExpiryYear());

    if (start != null && expiration != null && start.after(expiration)) {
        errors.rejectValue("startMonth", "payment.startDate.invalid");
    }/*from   w w w .j  av a  2 s .  co  m*/

    final boolean editMode = StringUtils.isNotBlank(form.getPaymentId());
    if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.titleCode", "address.title.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName",
                "address.firstName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName",
                "address.lastName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity",
                "address.townCity.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode",
                "address.postcode.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso",
                "address.country.invalid");
        // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line2", "address.line2.invalid"); // for some addresses this field is required by cybersource
    }
}

From source file:de.hshannover.f4.trust.irondetectprocedures.MeanDaily.java

/**
 * Calculates the duration in days from start to end. Example:
 * 1.1.2011 to 5.1.2011 would return 5./*from w w w.  j av a 2  s  .c  om*/
 * @param start
 * @param end
 * @return 
 */
private int durationInDays(Calendar start, Calendar end) {
    int duration = 0;
    if (start.after(end)) {
        logger.error("can not determine duration of training data. start date is after end date.");
        return duration;
    }
    // check years (leap years are ignored)
    duration += (end.get(Calendar.YEAR) - start.get(Calendar.YEAR)) * 365;
    // check days
    duration += end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR) + 1;
    return duration;
}

From source file:blankd.acme.pet.licensing.rest.controller.LicenseRestController.java

private Boolean isLicenseExpired(License l) {
    Calendar today = Calendar.getInstance();
    if (l.getExpires() == null) {
        return true;
    } else {/*w  w w.jav a  2  s .  c o  m*/
        return today.after(l.getExpires());
    }
}

From source file:org.kuali.kra.award.paymentreports.awardreports.reporting.service.ReportTrackingNotificationServiceImpl.java

/**
 * Is date1 after from and before until?
 * @param date1/*from  www . jav  a 2s . co m*/
 * @param from
 * @param until
 * @return
 */
protected boolean doDatesMatch(Date date1, Calendar from, Calendar until) {
    Calendar cal1 = Calendar.getInstance();
    cal1.setTime(date1);
    clearTimeFields(cal1);
    return cal1.after(from) && (cal1.equals(until) || cal1.before(until));
}

From source file:org.training.storefront.forms.validation.PaymentDetailsValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final PaymentDetailsForm form = (PaymentDetailsForm) object;

    final Calendar start = parseDate(form.getStartMonth(), form.getStartYear());
    final Calendar expiration = parseDate(form.getExpiryMonth(), form.getExpiryYear());

    if (start != null && expiration != null && start.after(expiration)) {
        errors.rejectValue("startMonth", "payment.startDate.invalid");
    }/*from   w ww  . j a  v  a2 s  .c o m*/

    final boolean editMode = StringUtils.isNotBlank(form.getPaymentId());
    if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.titleCode", "address.title.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName",
                "address.firstName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName",
                "address.lastName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity",
                "address.townCity.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode",
                "address.postcode.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso",
                "address.country.invalid");
        // ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line2", "address.line2.invalid"); // for some addresses this field is required by cybersource
    }
}

From source file:com.exxonmobile.ace.hybris.storefront.forms.validation.PaymentDetailsValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final PaymentDetailsForm form = (PaymentDetailsForm) object;

    final Calendar start = parseDate(form.getStartMonth(), form.getStartYear());
    final Calendar expiration = parseDate(form.getExpiryMonth(), form.getExpiryYear());

    if (start != null && expiration != null && start.after(expiration)) {
        errors.rejectValue("startMonth", "payment.startDate.invalid");
    }//from w  ww.ja v a 2s.co  m

    final boolean editMode = StringUtils.isNotBlank(form.getPaymentId());
    if (editMode || Boolean.TRUE.equals(form.getNewBillingAddress())) {
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.titleCode", "address.title.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.firstName",
                "address.firstName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.lastName",
                "address.lastName.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line1", "address.line1.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.townCity",
                "address.townCity.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.postcode",
                "address.postcode.invalid");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.countryIso",
                "address.country.invalid");
        //         ValidationUtils.rejectIfEmptyOrWhitespace(errors, "billingAddress.line2", "address.line2.invalid"); // for some addresses this field is required by cybersource
    }
}

From source file:com.github.notizklotz.derbunddownloader.download.AutomaticIssueDownloadAlarmManager.java

private Calendar calculateNextAlarm(int hourOfDay, int minute) {
    final Calendar nextAlarm = Calendar.getInstance();
    nextAlarm.clear();/*w w w  .  j  a  va2  s. c  om*/
    final Calendar now = Calendar.getInstance();

    nextAlarm.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH), hourOfDay,
            minute);

    //Make sure trigger is in the future
    if (now.after(nextAlarm)) {
        nextAlarm.add(Calendar.DAY_OF_MONTH, 1);
    }
    //Do not schedule Sundays as the newspaper is not issued on Sundays
    if ((nextAlarm.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) {
        nextAlarm.add(Calendar.DAY_OF_MONTH, 1);
    }
    return nextAlarm;
}