List of usage examples for java.time LocalDate equals
@Override public boolean equals(Object obj)
From source file:com.romeikat.datamessie.core.processing.task.documentProcessing.DocumentsProcessingTask.java
private void prepareForNextIteration(final TaskExecution taskExecution, final MutableObject<LocalDate> downloadedDate, final List<Document> documentsToProcess) throws TaskCancelledException { // No documents to process due to an error while loading final boolean errorOccurred = documentsToProcess == null; if (errorOccurred) { // In case of an error, wait and continue with same downloaded date sessionProvider.closeStatelessSession(); taskExecution.checkpoint(pause); // Next download date to be processed is the same return;// w w w . j a va 2 s . c om } // No documents to process for that downloaded date final boolean noDocumentsToProcess = documentsToProcess.isEmpty(); if (noDocumentsToProcess) { // Determine next downloaded date final LocalDate previousDownloadDate = downloadedDate.getValue(); final LocalDate nextDownloadedDate = getNextDownloadedDate(previousDownloadDate); // Current date is reached final boolean isCurrentDate = previousDownloadDate.equals(nextDownloadedDate); if (isCurrentDate) { // Pause sessionProvider.closeStatelessSession(); taskExecution.checkpoint(pause); // Next downloaded date to be processed is the same } // Current date is not yet reached else { // Next downloaded date to be processed is the next day downloadedDate.setValue(nextDownloadedDate); } return; } // No more documents to process for that downloaded date final boolean noMoreDocumentsToProcess = documentsToProcess.size() < batchSize; if (noMoreDocumentsToProcess) { // Increase download date // Determine next downloaded date final LocalDate previousDownloadDate = downloadedDate.getValue(); final LocalDate nextDownloadedDate = getNextDownloadedDate(previousDownloadDate); // Current date is reached final boolean isCurrentDate = previousDownloadDate.equals(nextDownloadedDate); if (isCurrentDate) { // Pause sessionProvider.closeStatelessSession(); taskExecution.checkpoint(pause); // Next downloaded date to be processed is the same } // Current date is not yet reached else { // Next downloaded date to be processed is the next day downloadedDate.setValue(nextDownloadedDate); } } }
From source file:com.github.drbookings.model.data.manager.MainManager.java
private void fillMissing() { final List<LocalDate> dates = new ArrayList<>(uiDataMap.keySet()); Collections.sort(dates);//from w ww .ja va 2 s .c o m final Collection<LocalDate> toAdd = new HashSet<>(); LocalDate last = null; for (final LocalDate d : dates) { if (last != null) { if (d.equals(last.plusDays(1))) { // ok } else { toAdd.addAll(new DateRange(last.plusDays(1), d.minusDays(1)).toList()); } } last = d; } for (final LocalDate d : toAdd) { addDateBean(new DateBean(d, this)); } }
From source file:investiagenofx2.view.InvestiaGenOFXController.java
private void getAccountsInvestmentsFromWeb() { @SuppressWarnings(("unchecked")) List<HtmlTable> tables = (List<HtmlTable>) htmlPage .getByXPath("//table[contains(@class, 'table-striped')]"); @SuppressWarnings(("unchecked")) List<HtmlDivision> divBalancesAs = (List<HtmlDivision>) htmlPage .getByXPath("//div[contains(text(),'Soldes au')]"); LocalDate balancesAs = LocalDate.parse(divBalancesAs.get(0).asText().replace("Soldes au ", ""), DateTimeFormatter.ofPattern("dd MMMM yyyy", Locale.CANADA_FRENCH)); int i = 0;/*from w ww. j a v a 2 s. co m*/ for (HtmlTable table : tables) { if (!table.asText().contains("Numro de \r\n compte")) { continue; } if (accounts.get(i).getAccountID() == null) { accounts.get(i).setAccountID(table.getCellAt(1, 3).getTextContent()); } Float total = 0f; for (int j = 1; j < table.getRowCount(); j++) { String symbol = table.getCellAt(j, 1).getTextContent(); String name = table.getCellAt(j, 0).getTextContent(); String quantity = table.getCellAt(j, 5).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String lastPrice = table.getCellAt(j, 6).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); String marketValue = table.getCellAt(j, 7).getTextContent().replaceAll("[^0-9,]", "").replace(",", "."); Investment investment = new Investment(symbol, name, quantity, lastPrice, marketValue); accounts.get(i).add(investment); total += Float.valueOf(marketValue); } String totalString = String.format("%.02f", total); Investment investment = new Investment("", "Total", totalString, "1.00", totalString); accounts.get(i).add(investment); if (!balancesAs.equals(dataAsDate)) accounts.get(i).setBalanceDate(balancesAs); i++; } if (!balancesAs.equals(dataAsDate)) dataAsDate = balancesAs; }
From source file:net.tourbook.photo.internal.manager.PhotoImageLoader.java
/** * Get image from thumb store with the requested image quality. * //from w w w . j a va 2 s . c o m * @param _photo * @param requestedImageQuality * @return */ private Image loadImageFromStore(final ImageQuality requestedImageQuality) { /* * check if image is available in the thumbstore */ final IPath requestedStoreImageFilePath = ThumbnailStore.getStoreImagePath(_photo, requestedImageQuality); final String imageStoreFilePath = requestedStoreImageFilePath.toOSString(); final File storeImageFile = new File(imageStoreFilePath); if (storeImageFile.isFile() == false) { return null; } // photo image is available in the thumbnail store Image storeImage = null; /* * touch store file when it is not yet done today, this is done to track last access time so * that a store cleanup can check the date */ final LocalDate dtModified = TimeTools.getZonedDateTime(storeImageFile.lastModified()).toLocalDate(); if (dtModified.equals(LocalDate.now()) == false) { storeImageFile.setLastModified(TimeTools.now().toInstant().toEpochMilli()); } try { storeImage = new Image(_display, imageStoreFilePath); loadImageProperties(requestedStoreImageFilePath); } catch (final Exception e) { StatusUtil.log(NLS.bind("Image cannot be loaded with SWT (1): \"{0}\"", //$NON-NLS-1$ imageStoreFilePath), e); } finally { if (storeImage == null) { String message = "Image \"{0}\" cannot be loaded and an exception did not occure.\n" //$NON-NLS-1$ + "The image file is available but it's possible that SWT.ERROR_NO_HANDLES occured"; //$NON-NLS-1$ System.out.println(UI.timeStampNano() + NLS.bind(message, imageStoreFilePath)); PhotoImageCache.disposeThumbs(null); /* * try loading again */ try { storeImage = new Image(_display, imageStoreFilePath); } catch (final Exception e) { StatusUtil.log(NLS.bind("Image cannot be loaded with SWT (2): \"{0}\"", //$NON-NLS-1$ imageStoreFilePath), e); } finally { if (storeImage == null) { message = "Image cannot be loaded again with SWT, even when disposing the image cache: \"{0}\" "; //$NON-NLS-1$ System.out.println(UI.timeStampNano() + NLS.bind(message, imageStoreFilePath)); } } } } return storeImage; }