List of usage examples for org.joda.time LocalDate compareTo
public int compareTo(ReadablePartial partial)
From source file:gg.db.datamodel.Periods.java
License:Open Source License
/** * Sets the start date of the period//from w w w. j a v a 2 s .co m * @param start Start date of the period */ private void setStart(LocalDate start) { if (start == null) { throw new IllegalArgumentException("The parameter 'start' is null"); } // Make sure that the Periods is valid if (end != null && start.compareTo(end) > 0) { // The start date is after the end date --> the Periods object is not valid throw new IllegalArgumentException( "The period is not valid: the start date (" + start + ") is after the end date (" + end + ")"); } this.start = start; }
From source file:gg.db.datamodel.Periods.java
License:Open Source License
/** * Sets the end date of the period//from ww w.j a v a 2 s . c o m * @param end End date of the period */ private void setEnd(LocalDate end) { if (end == null) { throw new IllegalArgumentException("The parameter 'end' is null"); } // Make sure that the Periods is valid if (start != null && end.compareTo(start) < 0) { // The start date is after the end date --> the Periods object is not valid throw new IllegalArgumentException( "The period is not valid: the start date (" + start + ") is after the end date (" + end + ")"); } this.end = end; }
From source file:gg.searchfilter.SearchFilterTopComponent.java
License:Open Source License
/** When the button 'Search' is clicked, creates a searchfilter object and put it in the lookup */ public void search() { log.entering(this.getClass().getName(), "search"); // A search can be performed only by the views that support the search button if (!jButtonSearch.isVisible()) { return;/* ww w . ja v a 2s .c o m*/ } // A search can be performed only if a Grisbi file has already been imported into the embedded DB if (Wallet.getInstance().getCurrenciesWithId().size() == 0) { return; } if (jXDatePickerFrom.getDate() == null) { // 'from' date has not been entered NotifyDescriptor message = new NotifyDescriptor.Message( NbBundle.getMessage(SearchFilterTopComponent.class, "SearchFilterTopComponent.FromMandatory"), NotifyDescriptor.WARNING_MESSAGE); message.setTitle(Constants.APPLICATION_TITLE); DialogDisplayer.getDefault().notify(message); return; } if (jXDatePickerTo.getDate() == null) { // 'to' date has not been entered NotifyDescriptor message = new NotifyDescriptor.Message( NbBundle.getMessage(SearchFilterTopComponent.class, "SearchFilterTopComponent.ToMandatory"), NotifyDescriptor.WARNING_MESSAGE); message.setTitle(Constants.APPLICATION_TITLE); DialogDisplayer.getDefault().notify(message); return; } // Get the 'from' and 'to' dates LocalDate from; LocalDate to; if (jXDatePickerFrom.getDate() != null) { from = new LocalDate(jXDatePickerFrom.getDate()); } else { from = new LocalDate(1990, 1, 1); } if (jXDatePickerTo.getDate() != null) { to = new LocalDate(jXDatePickerTo.getDate()); } else { to = new LocalDate(); } // Check that 'from' is before 'to' if (from.compareTo(to) > 0) { NotifyDescriptor message = new NotifyDescriptor.Message( NbBundle.getMessage(SearchFilterTopComponent.class, "SearchFilterTopComponent.InvalidPeriod"), NotifyDescriptor.WARNING_MESSAGE); message.setTitle(Constants.APPLICATION_TITLE); DialogDisplayer.getDefault().notify(message); return; } // Get 'by' (type of period: day, week, month, year) PeriodType periodType; if (jComboBoxBy.isVisible()) { assert (jComboBoxBy.getSelectedIndex() != -1); periodType = (PeriodType) jComboBoxBy.getSelectedItem(); assert (periodType != null); // Check that the number of periods is not too big Periods periods = new Periods(from, to, periodType); assert (periods != null); int maxNumberPeriods = Options.getMaxPeriods(); // Get the max number of periods allowed in the options if (periods.getPeriods().size() > maxNumberPeriods) { NotifyDescriptor message = new NotifyDescriptor.Message( NbBundle.getMessage(SearchFilterTopComponent.class, "SearchFilterTopComponent.MaxPeriods", new Object[] { maxNumberPeriods }), NotifyDescriptor.WARNING_MESSAGE); message.setTitle(Constants.APPLICATION_TITLE); DialogDisplayer.getDefault().notify(message); return; } } else { // Transactions view String storedPeriodTypeString = NbPreferences.forModule(SearchFilterTopComponent.class) .get(PERIOD_TYPE_KEY, PeriodType.WEEK.name()); periodType = PeriodType.valueOf(storedPeriodTypeString); } // Save 'from', 'to' and 'by' fields so that they will be loaded by default when the component will be opened NbPreferences.forModule(SearchFilterTopComponent.class).putLong(DATE_FROM_KEY, new DateTime(jXDatePickerFrom.getDate()).getMillis()); NbPreferences.forModule(SearchFilterTopComponent.class).putLong(DATE_TO_KEY, new DateTime(jXDatePickerTo.getDate()).getMillis()); NbPreferences.forModule(SearchFilterTopComponent.class).put(PERIOD_TYPE_KEY, periodType.name()); // Get selected currency Object selectedCurrencyObject = jComboBoxCurrency.getSelectedItem(); assert (selectedCurrencyObject != null); Currency selectedCurrency = (Currency) selectedCurrencyObject; assert (selectedCurrency != null); // Get selected accounts List<Account> selectedAccounts = new ArrayList<Account>(); int[] selectedAccountsIndices = jListAccounts.getSelectedIndices(); for (int i = 0; i < selectedAccountsIndices.length; i++) { Object selectedAccountObject = jListAccounts.getModel().getElementAt(selectedAccountsIndices[i]); assert (selectedAccountObject != null); selectedAccounts.add((Account) selectedAccountObject); } // Get selected categories List<Category> selectedCategories = new ArrayList<Category>(); TreePath[] paths = jTreeCategories.getSelectionPaths(); if (paths != null) { // category selected for (TreePath path : paths) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); assert (node != null); Object selectedCategoryObject = node.getUserObject(); assert (selectedCategoryObject != null); Category category = (Category) selectedCategoryObject; assert (category != null); selectedCategories.add(category); } } // Get selected payees List<Payee> selectedPayees = new ArrayList<Payee>(); int[] selectedPayeesIndices = jListPayees.getSelectedIndices(); for (int i = 0; i < selectedPayeesIndices.length; i++) { Object selectedPayeeObject = jListPayees.getModel().getElementAt(selectedPayeesIndices[i]); assert (selectedPayeeObject != null); selectedPayees.add((Payee) selectedPayeeObject); } // Get selected keywords String keywords = jTextFieldKeywords.getText(); // Create the search filter SearchFilter searchFilter = new SearchFilter(from, to, periodType, selectedCurrency, selectedAccounts, selectedCategories, selectedPayees, keywords); // Put the search filter in the lookup of the TC content.set(Collections.singleton(searchFilter), null); log.exiting(this.getClass().getName(), "search"); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.serviceRequests.documentRequests.CreatePastDiplomaRequest.java
License:Open Source License
private static void createSituations(PastDiplomaRequest request, DocumentRequestCreateBean bean) { if (!bean.getRegistration().isRegistrationConclusionProcessed()) { throw new DomainException("DiplomaRequest.diploma.cannot.be.concluded"); }/*ww w . j ava 2 s . c o m*/ LocalDate latestDate = bean.getPastRequestDate(); if (bean.getPastPaymentDate() == null) { bean.setPastPaymentDate(latestDate); } else { latestDate = (latestDate.compareTo(bean.getPastPaymentDate()) < 0) ? bean.getPastPaymentDate() : latestDate; } if (bean.getPastEmissionDate() == null) { bean.setPastEmissionDate(latestDate); } else { latestDate = (latestDate.compareTo(bean.getPastEmissionDate()) < 0) ? bean.getPastEmissionDate() : latestDate; } if (bean.getPastDispatchDate() == null) { bean.setPastDispatchDate(latestDate); } createPaymentSituation(request, bean); process(request, bean.getPastRequestDate()); request.setNumberOfPages(1); send(request, bean.getPastRequestDate()); receive(request, bean.getPastRequestDate()); conclude(request, bean.getPastEmissionDate()); deliver(request, bean.getPastDispatchDate()); }
From source file:nz.co.jsrsolutions.util.QuoteDateComparator.java
License:Open Source License
@Override public int compare(QUOTE o1, QUOTE o2) { final DateTime first = new DateTime(o1.getDateTime()); final DateTime second = new DateTime(o2.getDateTime()); final LocalDate firstDate = first.toLocalDate(); final LocalDate secondDate = second.toLocalDate(); return firstDate.compareTo(secondDate); }
From source file:op.care.reports.PnlReport.java
License:Open Source License
private JPanel createContentPanel4Month(LocalDate month) { /***//from ww w .ja va 2s . com * _ _ __ __ __ ___ _ _ _____ _ _ * ___ ___ _ __ | |_ ___ _ __ | |_ / _| ___ _ __ | \/ |/ _ \| \ | |_ _| | | | * / __/ _ \| '_ \| __/ _ \ '_ \| __| | |_ / _ \| '__| | |\/| | | | | \| | | | | |_| | * | (_| (_) | | | | || __/ | | | |_ | _| (_) | | | | | | |_| | |\ | | | | _ | * \___\___/|_| |_|\__\___|_| |_|\__| |_| \___/|_| |_| |_|\___/|_| \_| |_| |_| |_| * */ // if (!contentmap.containsKey(key)) { JPanel pnlMonth = new JPanel(new VerticalLayout()); pnlMonth.setOpaque(false); LocalDate now = new LocalDate(); boolean sameMonth = now.dayOfMonth().withMaximumValue().equals(month.dayOfMonth().withMaximumValue()); final LocalDate start = sameMonth ? now : SYSCalendar.eom(month); final LocalDate end = SYSCalendar.bom(month); for (LocalDate week = start; end.compareTo(week) <= 0; week = week.minusWeeks(1)) { pnlMonth.add(createCP4Week(week)); } return pnlMonth; }
From source file:op.care.reports.PnlReport.java
License:Open Source License
private JPanel createContenPanel4Week(LocalDate week) { JPanel pnlWeek = new JPanel(new VerticalLayout()); pnlWeek.setOpaque(false);/*from ww w.j av a2s . co m*/ LocalDate now = new LocalDate(); boolean sameWeek = now.dayOfWeek().withMaximumValue().equals(week.dayOfWeek().withMaximumValue()); final LocalDate start = sameWeek ? now : SYSCalendar.eow(week); final LocalDate end = SYSCalendar.bow(week); for (LocalDate day = start; end.compareTo(day) <= 0; day = day.minusDays(1)) { pnlWeek.add(createCP4Day(day)); } return pnlWeek; }
From source file:op.care.supervisor.PnlHandover.java
License:Open Source License
private JPanel createContentPanel4Month(LocalDate month) { /***//from w w w. j a v a 2s .com * _ _ __ __ __ ___ _ _ _____ _ _ * ___ ___ _ __ | |_ ___ _ __ | |_ / _| ___ _ __ | \/ |/ _ \| \ | |_ _| | | | * / __/ _ \| '_ \| __/ _ \ '_ \| __| | |_ / _ \| '__| | |\/| | | | | \| | | | | |_| | * | (_| (_) | | | | || __/ | | | |_ | _| (_) | | | | | | |_| | |\ | | | | _ | * \___\___/|_| |_|\__\___|_| |_|\__| |_| \___/|_| |_| |_|\___/|_| \_| |_| |_| |_| * */ JPanel pnlMonth = new JPanel(new VerticalLayout()); pnlMonth.setOpaque(false); LocalDate now = new LocalDate(); boolean sameMonth = now.dayOfMonth().withMaximumValue().equals(month.dayOfMonth().withMaximumValue()); final LocalDate start = sameMonth ? now : month.dayOfMonth().withMaximumValue(); final LocalDate end = month.dayOfMonth().withMinimumValue(); for (LocalDate day = start; end.compareTo(day) <= 0; day = day.minusDays(1)) { pnlMonth.add(createCP4Day(day)); } return pnlMonth; }
From source file:orc.lib.orchard.forms.DateTimeRangesField.java
License:Open Source License
private void renderHour(final PrintWriter out, final int hour) throws IOException { out.write("<tr>"); out.write("<th>"); out.write(formatHour(hour));//from ww w . ja v a 2 s. co m out.write("</th>"); LocalDate current = span.getStart(); final LocalDate end = span.getEnd(); final LocalTime time = new LocalTime(hour, 0); while (current.compareTo(end) < 0) { out.write("<td>"); renderTime(out, current.toDateTime(time)); out.write("</td>"); current = current.plusDays(1); } out.write("</tr>"); }
From source file:orc.lib.orchard.forms.DateTimeRangesField.java
License:Open Source License
private void renderTableHeader(final PrintWriter out) throws IOException { out.write("<tr><th> </th>"); LocalDate current = span.getStart(); final LocalDate end = span.getEnd(); while (current.compareTo(end) < 0) { out.write("<th>"); out.write(formatDateHeader(current)); out.write("</th>"); current = current.plusDays(1);/* w w w.j a va 2 s . c o m*/ } out.write("</tr>"); }