List of usage examples for java.time LocalDate now
public static LocalDate now()
From source file:org.pentaho.di.www.cache.CarteStatusCache.java
@Override public void clear() throws CacheException { cachedMap.forEach((k, v) -> {//from w ww . ja va2 s .co m if (LocalDate.now().isAfter(v.getExceedTime())) { remove(k); } }); }
From source file:jgnash.ui.report.compiled.PayeePieChart.java
private JPanel createPanel() { JButton refreshButton = new JButton(rb.getString("Button.Refresh")); JButton addFilterButton = new JButton(rb.getString("Button.AddFilter")); final JButton saveButton = new JButton(rb.getString("Button.SaveFilters")); JButton deleteFilterButton = new JButton(rb.getString("Button.DeleteFilter")); JButton clearPrefButton = new JButton(rb.getString("Button.MasterDelete")); filterCombo = new JComboBox<>(); startField = new DatePanel(); endField = new DatePanel(); txtAddFilter = new TextField(); filterList = new ArrayList<>(); filtersChanged = false;/*from ww w . j a va 2 s . c o m*/ useFilters = new JCheckBox(rb.getString("Label.UseFilters")); useFilters.setSelected(true); showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues")); combo = AccountListComboBox.getFullInstance(); final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now().minusYears(1)); long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart)); startField.setDate(DateUtils.asLocalDate(start)); currentAccount = combo.getSelectedAccount(); PieDataset[] data = createPieDataSet(currentAccount); JFreeChart chartCredit = createPieChart(currentAccount, data, 0); chartPanelCredit = new ChartPanel(chartCredit, true, true, true, false, true); // (chart, properties, save, print, zoom, tooltips) JFreeChart chartDebit = createPieChart(currentAccount, data, 1); chartPanelDebit = new ChartPanel(chartDebit, true, true, true, false, true); FormLayout layout = new FormLayout("p, $lcgap, 70dlu, 8dlu, p, $lcgap, 70dlu, $ugap, p, $lcgap:g, left:p", "d, $rgap, d, $ugap, f:p:g, $rgap, d"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); layout.setRowGroups(new int[][] { { 1, 3 } }); // row 1 builder.append(combo, 9); builder.append(useFilters); builder.nextLine(); builder.nextLine(); // row 3 builder.append(rb.getString("Label.StartDate"), startField); builder.append(rb.getString("Label.EndDate"), endField); builder.append(refreshButton); builder.append(showPercentCheck); builder.nextLine(); builder.nextLine(); // row 5 FormLayout subLayout = new FormLayout("180dlu:g, 1dlu, 180dlu:g", "f:180dlu:g"); DefaultFormBuilder subBuilder = new DefaultFormBuilder(subLayout); subBuilder.append(chartPanelCredit); subBuilder.append(chartPanelDebit); builder.append(subBuilder.getPanel(), 11); builder.nextLine(); builder.nextLine(); // row 7 builder.append(txtAddFilter, 3); builder.append(addFilterButton, 3); builder.append(saveButton); builder.nextLine(); // row builder.append(filterCombo, 3); builder.append(deleteFilterButton, 3); builder.append(clearPrefButton); builder.nextLine(); JPanel panel = builder.getPanel(); combo.addActionListener(e -> { Account newAccount = combo.getSelectedAccount(); if (filtersChanged) { int result = JOptionPane.showConfirmDialog(null, rb.getString("Message.SaveFilters"), "Warning", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { saveButton.doClick(); } } filtersChanged = false; String[] list = POUND_DELIMITER_PATTERN.split(pref.get(FILTER_TAG + newAccount.hashCode(), "")); filterList.clear(); for (String filter : list) { if (!filter.isEmpty()) { //System.out.println("Adding filter: #" + filter + "#"); filterList.add(filter); } } refreshFilters(); setCurrentAccount(newAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); refreshButton.addActionListener(e -> { setCurrentAccount(currentAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); clearPrefButton.addActionListener(e -> { int result = JOptionPane.showConfirmDialog(null, rb.getString("Message.MasterDelete"), "Warning", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { try { pref.clear(); } catch (Exception ex) { System.out.println("Exception clearing preferences" + ex); } } }); saveButton.addActionListener(e -> { final StringBuilder sb = new StringBuilder(); for (String filter : filterList) { sb.append(filter); sb.append('#'); } //System.out.println("Save = " + FILTER_TAG + currentAccount.hashCode() + " = " + sb.toString()); pref.put(FILTER_TAG + currentAccount.hashCode(), sb.toString()); filtersChanged = false; }); addFilterButton.addActionListener(e -> { String newFilter = txtAddFilter.getText(); filterList.remove(newFilter); if (!newFilter.isEmpty()) { filterList.add(newFilter); filtersChanged = true; txtAddFilter.setText(""); } refreshFilters(); }); deleteFilterButton.addActionListener(e -> { if (!filterList.isEmpty()) { String filter = (String) filterCombo.getSelectedItem(); filterList.remove(filter); filtersChanged = true; } refreshFilters(); }); useFilters.addActionListener(e -> setCurrentAccount(currentAccount)); showPercentCheck.addActionListener(e -> { ((PiePlot) chartPanelCredit.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels); ((PiePlot) chartPanelDebit.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels); }); return panel; }
From source file:org.openlmis.fulfillment.testutils.DtoGenerator.java
private static Object generateBaseValue(Class<?> propertyType) { if (String.class.isAssignableFrom(propertyType)) { return randomAlphanumeric(10); }/*from w w w . j a va 2 s . c o m*/ if (Number.class.isAssignableFrom(propertyType)) { return parseNumber(String.valueOf(RANDOM.nextInt(1000)), (Class<Number>) propertyType); } if (UUID.class.isAssignableFrom(propertyType)) { return randomUUID(); } if (Boolean.class.isAssignableFrom(propertyType) || boolean.class.isAssignableFrom(propertyType)) { return true; } if (LocalDate.class.isAssignableFrom(propertyType)) { return LocalDate.now(); } if (ZonedDateTime.class.isAssignableFrom(propertyType)) { return ZonedDateTime.now(); } if (Enum.class.isAssignableFrom(propertyType)) { int idx = RANDOM.nextInt(propertyType.getEnumConstants().length); return propertyType.getEnumConstants()[idx]; } return null; }
From source file:mesclasses.view.RapportEleveController.java
public void init() { name += " for lve " + eleve; rapportLabel.setText("Rapport pour " + eleve.getDisplayName()); if (trimestres != null && !trimestres.isEmpty()) { Trimestre current = model.getForDate(LocalDate.now()); selectTrimestre(current != null ? trimestres.indexOf(current) : 0); }//ww w . j a v a 2s. co m refreshGrid(); }
From source file:retsys.client.controller.PurchaseOrderConfirmController.java
/** * Initializes the controller class./* w w w . j a v a2s . co m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { po_date.setValue(LocalDate.now()); loc_of_material.setCellValueFactory(new PropertyValueFactory<POItem, String>("location")); material_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("name")); brand_name.setCellValueFactory(new PropertyValueFactory<POItem, String>("brand")); model_code.setCellValueFactory(new PropertyValueFactory<POItem, String>("model")); quantity.setCellValueFactory(new PropertyValueFactory<POItem, Integer>("quantity")); confirm.setCellValueFactory(new PropertyValueFactory<POItem, Boolean>("confirm")); confirm.setCellFactory(CheckBoxTableCell.forTableColumn(confirm)); billNo.setCellValueFactory(new PropertyValueFactory<POItem, String>("billNo")); billNo.setCellFactory(TextFieldTableCell.forTableColumn()); supervisor.setCellValueFactory(new PropertyValueFactory<POItem, String>("supervisor")); supervisor.setCellFactory(TextFieldTableCell.forTableColumn()); receivedDate.setCellValueFactory(new PropertyValueFactory<POItem, LocalDate>("receivedDate")); receivedDate.setCellFactory(new Callback<TableColumn<POItem, LocalDate>, TableCell<POItem, LocalDate>>() { @Override public TableCell<POItem, LocalDate> call(TableColumn<POItem, LocalDate> param) { TableCell<POItem, LocalDate> cell = new TableCell<POItem, LocalDate>() { @Override protected void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. if (empty || item == null) { setText(null); setGraphic(null); } else { setText(formatter.format(item)); } } @Override public void startEdit() { super.startEdit(); System.out.println("start edit"); DatePicker dateControl = null; if (this.getItem() != null) { dateControl = new DatePicker(this.getItem()); } else { dateControl = new DatePicker(); } dateControl.valueProperty().addListener(new ChangeListener<LocalDate>() { @Override public void changed(ObservableValue<? extends LocalDate> observable, LocalDate oldValue, LocalDate newValue) { if (newValue == null) { cancelEdit(); } else { commitEdit(newValue); } } }); this.setGraphic(dateControl); } @Override public void cancelEdit() { super.cancelEdit(); System.out.println("cancel edit"); setGraphic(null); if (this.getItem() != null) { setText(formatter.format(this.getItem())); } else { setText(null); } } @Override public void commitEdit(LocalDate newValue) { super.commitEdit(newValue); System.out.println("commit edit"); setGraphic(null); setText(formatter.format(newValue)); } }; return cell; } }); poDetail.getColumns().setAll(loc_of_material, material_name, brand_name, model_code, quantity, confirm, receivedDate, billNo, supervisor); AutoCompletionBinding<PurchaseOrder> bindForTxt_name = TextFields.bindAutoCompletion(project, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<PurchaseOrder>>() { @Override public Collection<PurchaseOrder> call(AutoCompletionBinding.ISuggestionRequest param) { List<PurchaseOrder> list = null; try { LovHandler lovHandler = new LovHandler("purchaseorders", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<PurchaseOrder>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<PurchaseOrder>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<PurchaseOrder>() { @Override public String toString(PurchaseOrder object) { System.out.println("here..." + object); String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format( LocalDateTime.ofInstant(object.getDate().toInstant(), ZoneId.systemDefault())); return "Project:" + object.getProject().getName() + " PO Date:" + strDate + " PO No.:" + object.getId(); } @Override public PurchaseOrder fromString(String string) { throw new UnsupportedOperationException(); } }); bindForTxt_name .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<PurchaseOrder>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<PurchaseOrder> event) { populateData(event.getCompletion()); } }); AutoCompletionBinding<Vendor> bindForVendor = TextFields.bindAutoCompletion(vendor, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Vendor>>() { @Override public Collection<Vendor> call(AutoCompletionBinding.ISuggestionRequest param) { List<Vendor> list = null; try { LovHandler lovHandler = new LovHandler("vendors", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Vendor>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Vendor>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Vendor>() { @Override public String toString(Vendor object) { return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Vendor fromString(String string) { throw new UnsupportedOperationException(); } }); }
From source file:alfio.manager.system.DataMigratorIntegrationTest.java
private Pair<Event, String> initEvent(List<TicketCategoryModification> categories, String displayName) { String organizationName = UUID.randomUUID().toString(); String username = UUID.randomUUID().toString(); String eventName = UUID.randomUUID().toString(); organizationRepository.create(organizationName, "org", "email@example.com"); Organization organization = organizationRepository.findByName(organizationName).get(); userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR, User.Type.INTERNAL); Map<String, String> desc = new HashMap<>(); desc.put("en", "muh description"); desc.put("it", "muh description"); desc.put("de", "muh description"); EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", null, null, eventName, displayName, organization.getId(), "muh location", "0.0", "0.0", ZoneId.systemDefault().getId(), desc, new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)), BigDecimal.TEN, "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, null, categories, false, new LocationDescriptor("", "", "", ""), 7, null, null); eventManager.createEvent(em);// w w w . ja va 2 s .c o m return Pair.of(eventManager.getSingleEvent(eventName, username), username); }
From source file:org.silverpeas.core.calendar.CalendarSynchronizationIT.java
@Test public void synchronizeFromAnEmptyCalendarShouldDoesNothing() throws Exception { Calendar calendar = prepareCalendarWithExternal(emptyExternalUrl); ICalendarImportResult result = calendar.synchronize(); assertThat(result.isEmpty(), is(true)); calendar = Calendar.getById(calendar.getId()); assertThat(calendar.getLastSynchronizationDate().isPresent(), is(true)); assertThat(calendar.getLastSynchronizationDate().get().toLocalDate(), is(LocalDate.now())); assertThat(calendar.isEmpty(), is(true)); }
From source file:newcontroller.handler.impl.DefaultRequestTest.java
@Test public void testModel() throws Exception { HttpServletRequest request = MockMvcRequestBuilders.get("/").buildRequest(new MockServletContext()); Request req = new DefaultRequest(request); LocalDate now = LocalDate.now(); req.put("foo", 100).put("bar", "hoge").put("piyo", now); Map<String, Object> expected = new LinkedHashMap<>(); expected.put("foo", 100); expected.put("bar", "hoge"); expected.put("piyo", now); assertThat(req.model(), is(expected)); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUnboundedEventGeneration() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();/*from w w w . j ava 2 s . c o m*/ List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); assertEquals(AVAILABLE_SEATS, tickets.stream().filter(t -> t.getCategoryId() == null).count()); List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); assertEquals(1, ticketCategories.size()); assertEquals(0, ticketCategories.get(0).getMaxTickets()); }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveExistingCategoryNotEnoughSeatsNotBoundedSoldOut() throws Exception { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 1, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); performExistingCategoryTest(categories, false, Collections.singletonList(1), true, true, AVAILABLE_SEATS, AVAILABLE_SEATS + 1);/*from www . ja va 2 s . c o m*/ }