List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate(Object instant)
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.InvoiceBean.java
License:Apache License
public void addNewTimesheetListener(ActionEvent event) { dateFromTimesheet = new LocalDate(selectedInvoiceEntity.getFromDate()); dateToTimesheet = new LocalDate(selectedInvoiceEntity.getToDate()); //refresh/* w w w . ja v a 2s . c o m*/ selectedInvoiceItemsEntity = invoiceDAO.getInvoiceItemsRepository() .findOne(selectedInvoiceItemsEntity.getInvoiceItemId()); //now search actual minimum date in the date for the entry and compare to invoice date. Use less of the two. selectedInvoiceItemsEntity.getTimeSheetsByInvoiceItemId().stream() .min((o1, o2) -> o1.getItemDate().compareTo(o2.getItemDate())) .ifPresent(timeSheetEntity -> dateFromTimesheet = timeSheetEntity.getItemDate() .compareTo(dateFromTimesheet.toDate()) > 0 ? dateFromTimesheet : new LocalDate(timeSheetEntity.getItemDate())); //search max date from the one of the invoice and the database data and use larger one selectedInvoiceItemsEntity.getTimeSheetsByInvoiceItemId().stream() .max((o1, o2) -> o1.getItemDate().compareTo(o2.getItemDate())) .ifPresent(timeSheetEntity -> dateToTimesheet = timeSheetEntity.getItemDate() .compareTo(dateToTimesheet.toDate()) < 0 ? dateToTimesheet : new LocalDate(timeSheetEntity.getItemDate())); //1-mon ... 7-sun final Integer weekStart = selectedInvoiceEntity.getCompaniesByCompanyTo().getWeekStart(); final Integer weekEnd = selectedInvoiceEntity.getCompaniesByCompanyTo().calculateWeekEnd(); if (dateFromTimesheet.getDayOfWeek() - weekStart < 0) { dateFromTimesheet = dateFromTimesheet.minusWeeks(1).withDayOfWeek(weekStart); } else { dateFromTimesheet = dateFromTimesheet.withDayOfWeek(weekStart); } if (dateToTimesheet.getDayOfWeek() - weekEnd <= 0) { dateToTimesheet = dateToTimesheet.withDayOfWeek(weekEnd); } else { dateToTimesheet = dateToTimesheet.plusWeeks(1).withDayOfWeek(weekEnd); } }
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.InvoiceBean.java
License:Apache License
public void setDateFromTimesheet(Date dateFromTimesheet) { this.dateFromTimesheet = new LocalDate(dateFromTimesheet); }
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.InvoiceBean.java
License:Apache License
public void setDateToTimesheet(Date dateToTimesheet) { this.dateToTimesheet = new LocalDate(dateToTimesheet); }
From source file:com.c2a.vie.managedbeans.deces.ContratgroupeManagedBean.java
public int dureecontrat() { LocalDate dateeffet = new LocalDate(formContrat.getDateeffet().getTime()); LocalDate datefin = new LocalDate(formContrat.getDateexp().getTime()); return (Months.monthsBetween(dateeffet, datefin).getMonths()); }
From source file:com.c2a.vie.managedbeans.deces.ContratgroupeManagedBean.java
public int dureecontratren() { LocalDate dateeffet = new LocalDate(formrenvlmntcontrat.getDateeffet().getTime()); LocalDate datefin = new LocalDate(formrenvlmntcontrat.getDateexp().getTime()); return (Months.monthsBetween(dateeffet, datefin).getMonths()); }
From source file:com.c2a.vie.managedbeans.deces.ContratgroupeManagedBean.java
public int dureristourne() { LocalDate dateeffet = new LocalDate(new Date().getTime()); LocalDate datefin = new LocalDate(formrenvlmntcontrat.getDateexp().getTime()); return (Months.monthsBetween(dateeffet, datefin).getMonths()); }
From source file:com.cinco.InvoiceData.java
/** * Adds a particular equipment (corresponding to <code>productCode</code> to an * invoice corresponding to the provided <code>invoiceCode</code> with the given * begin/end dates/*www . j a va 2s. co m*/ */ public static void addLicenseToInvoice(String invoiceCode, String productCode, String startDate, String endDate) { Connection conn = null; PreparedStatement ps = null; try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(DataInfo.url, DataInfo.username, DataInfo.password); String equipmentInvoiceQuery = "INSERT INTO InvoiceProducts (InvoiceCode, ProductCode, Quantity) VALUES (?, ?, ?);"; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date start = null; try { start = df.parse(startDate); } catch (ParseException e) { e.printStackTrace(); } Date end = null; try { end = df.parse(endDate); } catch (ParseException e) { e.printStackTrace(); } double quantity = (Days.daysBetween(new LocalDate(start), new LocalDate(end)).getDays()); ps = conn.prepareStatement(equipmentInvoiceQuery); ps.setString(1, invoiceCode); ps.setString(2, productCode); ps.setDouble(3, quantity); ps.executeUpdate(); // String updateQuery = "UPDATE InvoiceProducts, Products SET InvoiceProducts.ProductID = Products.ProductID WHERE InvoiceProducts.ProductCode = Products.ProductCode;"; // ps.executeUpdate(updateQuery); // updateQuery = "UPDATE InvoiceProducts, Invoices SET InvoiceProducts.InvoiceID = Invoices.InvoiceID WHERE InvoiceProducts.InvoiceCode = Invoices.InvoiceCode;"; // ps.executeUpdate(updateQuery); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (conn != null) { conn.close(); } } catch (SQLException se) { se.printStackTrace(); } if (ps != null) { try { ps.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:com.clicktravel.common.random.Randoms.java
License:Apache License
/** * @return A random local date, between approximately year 1970 and year 6429. *//*from w ww. j ava 2s.c o m*/ public static LocalDate randomLocalDate() { return new LocalDate(randomDateTime()); }
From source file:com.constellio.app.services.appManagement.AppManagementService.java
License:Open Source License
private void removeAllFilesAndKeepTheNewestOneBeforeLastWeek(Collection<File> files) { List<File> filesList = new ArrayList<>(files); Collections.sort(filesList, new Comparator<File>() { @Override/*from w w w . ja v a 2 s .c om*/ public int compare(File o1, File o2) { LocalDate modificationDate1 = new LocalDate(o1.lastModified()); LocalDate modificationDate2 = new LocalDate(o1.lastModified()); return modificationDate1.compareTo(modificationDate2); } }); for (int i = 0; i < filesList.size() - 1; i++) { File file = filesList.get(i); FileUtils.deleteQuietly(file); } File lastFile = filesList.get(filesList.size() - 1); if (!isModifiedBeforeLastWeek(lastFile)) { FileUtils.deleteQuietly(lastFile); } }
From source file:com.constellio.app.services.appManagement.AppManagementService.java
License:Open Source License
boolean isModifiedBeforeLastWeek(File webAppsFolder) { return new LocalDate(webAppsFolder.lastModified()).isBefore(TimeProvider.getLocalDate().minusDays(7)); }