List of usage examples for java.time LocalDate now
public static LocalDate now()
From source file:retsys.client.controller.CreditNoteController.java
/** * Initializes the controller class./*from www . j av a 2 s .c o m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { creationDate.setValue(LocalDate.now()); itemName.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, String>("itemName")); itemAmount.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Double>("itemAmount")); returnQuantity.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Double>("returnQuantity")); confirm.setCellValueFactory(new PropertyValueFactory<CreditNoteItem, Boolean>("confirm")); confirm.setCellFactory(CheckBoxTableCell.forTableColumn(confirm)); creditNoteDetail.getColumns().setAll(itemName, itemAmount, returnQuantity, confirm); AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(name, new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() { @Override public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) { List<Item> list = null; try { LovHandler lovHandler = new LovHandler("items", "name"); String response = lovHandler.getSuggestions(param.getUserText()); list = (List<Item>) new JsonHelper().convertJsonStringToObject(response, new TypeReference<List<Item>>() { }); } catch (IOException ex) { Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex); } return list; } }, new StringConverter<Item>() { @Override public String toString(Item object) { System.out.println("here..." + object); return object.getName() + " (ID:" + object.getId() + ")"; } @Override public Item fromString(String string) { throw new UnsupportedOperationException(); } }); //event handler for setting other item fields with values from selected Item object //fires after autocompletion bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() { @Override public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) { Item item = event.getCompletion(); //fill other item related fields name.setText(item.getName() + " (ID:" + item.getId() + ")"); brand.setText(item.getBrand()); model.setText(null); //?? add model? amount.setText(item.getRate().toString()); quantity.setText(item.getQuantity().toString()); } }); 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:de.kaiserpfalzEdv.office.core.license.impl.LicenseImpl.java
private boolean isWithinValidityPeriod() { LocalDate now = LocalDate.now(); return (starts.isBefore(now) || starts.isEqual(now)) && (expires.isAfter(now) || expires.isEqual(now)); }
From source file:se.nrm.dina.naturarv.portal.controller.MainChart.java
/** * Initiate date now// ww w.j ava2 s . c o m */ private void initDate() { log.info("initDate"); isSwedish = language.isIsSwedish(); today = LocalDate.now(); year = today.getYear(); lastYear = year - 1; month = today.getMonthValue(); lastYearDate = LocalDate.of(lastYear, month, today.getDayOfMonth()); lastTenYear = year - 10; }
From source file:com.thesoftwareguild.capstoneblog.controller.HomeController.java
@RequestMapping(value = "/post", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/* w ww . j a v a2s. com*/ @ResponseBody public Post createPost(@Valid @RequestBody Content content) { // persist the incoming post if (content.getTitle() == null || content.getTitle().isEmpty()) { content.setTitle("Untitled"); } // parse categories into a list of strings List<String> categoriesList = new ArrayList<>(); if (!content.getCategories().isEmpty()) { String[] categoriesArr = content.getCategories().split(","); categoriesList.addAll(Arrays.asList(categoriesArr)); } // parse tags into a list of strings List<String> tagsList = new ArrayList<>(); String[] tagsArr = content.getTags().split(","); tagsList.addAll(Arrays.asList(tagsArr)); // TODO: parse comments Post p = new Post(content.getAuthor(), content.getTitle(), content.getText(), LocalDate.now() // date created , LocalDate.now() // date posted (set to created for now) , categoriesList // categories , tagsList // tags , new ArrayList<>()); // TODO: comments dao.addPost(p); return p; }
From source file:br.edu.ifpb.padroes.projeto.sisbiblioteca.model.EmprestimoBo.java
public void finalizaEmprestimo(Emprestimo emprestimo) throws EmprestimoAtrasadoException, EmprestimoJaFinalizadoException { try {/* w w w . j av a 2 s . c o m*/ emprestimo.finalizarEmprestimo(); finalizeEmprestimoOnDao(emprestimo); } catch (EmprestimoAtrasadoException ex) { LocalDate now = LocalDate.now(); Bloqueio bloqueio = new Bloqueio(now, now.plusDays(3), emprestimo.getAluno(), EstadoBloqueioEnum.ANDAMENTO); //insere o bloqueio! bloqueioDao.inserir(bloqueio); finalizeEmprestimoOnDao(emprestimo); throw new EmprestimoAtrasadoException("O Devoluo do emprstimo foi feita com sucesso" + " mas a entrega do mesmo atrasou. O Aluno ficar banido de realizar emprstimos" + " durante 3 dias! "); } }
From source file:com.github.drbookings.LocalDates.java
public static boolean isLastMonth(final LocalDate date) { final Month month = LocalDate.now().getMonth().minus(1); return date.getMonth().equals(month) && (date.getYear() == LocalDate.now().getYear() || date.getYear() == LocalDate.now().getYear() - 1); }
From source file:de.lgblaumeiser.ptm.rest.BookingControllerTest.java
@Test public void testRoundtripCreateAndRetrieveBooking() throws Exception { ActivityRestController.ActivityBody data = new ActivityRestController.ActivityBody(); data.activityName = "MyTestActivity"; data.bookingNumber = "0815"; mockMvc.perform(/*from w w w. j av a 2s . co m*/ post("/activities").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsString(data))) .andDo(print()).andExpect(status().isCreated()); LocalDate date = LocalDate.now(); String dateString = date.format(ISO_LOCAL_DATE); BookingRestController.BookingBody booking = new BookingRestController.BookingBody(); booking.activityId = "1"; booking.user = "TestUser"; booking.starttime = LocalTime.of(8, 15).format(ISO_LOCAL_TIME); booking.comment = ""; mockMvc.perform(post("/bookings/" + dateString).contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsString(booking))).andDo(print()).andExpect(status().isCreated()); mockMvc.perform(get("/bookings")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString(dateString))); mockMvc.perform(get("/bookings/" + dateString)).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString("MyTestActivity"))) .andExpect(content().string(containsString("0815"))) .andExpect(content().string(containsString("TestUser"))) .andExpect(content().string(containsString("starttime"))); mockMvc.perform(get("/bookings/" + dateString + "/1")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString("MyTestActivity"))) .andExpect(content().string(containsString("0815"))) .andExpect(content().string(containsString("TestUser"))) .andExpect(content().string(containsString("starttime"))); booking.endtime = LocalTime.of(16, 30).format(ISO_LOCAL_TIME); mockMvc.perform(post("/bookings/" + dateString + "/1").contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsString(booking))).andDo(print()).andExpect(status().isOk()); mockMvc.perform(get("/bookings/" + dateString + "/1")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString("MyTestActivity"))) .andExpect(content().string(containsString("0815"))) .andExpect(content().string(containsString("TestUser"))) .andExpect(content().string(containsString("starttime"))) .andExpect(content().string(containsString("endtime"))); LocalDate date2 = date.minusDays(1); String dateString2 = date2.format(ISO_LOCAL_DATE); booking = new BookingRestController.BookingBody(); booking.activityId = "1"; booking.user = "TestUser"; booking.starttime = LocalTime.of(8, 15).format(ISO_LOCAL_TIME); booking.endtime = LocalTime.of(16, 30).format(ISO_LOCAL_TIME); booking.comment = "Test Comment"; mockMvc.perform(post("/bookings/" + dateString2).contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsString(booking))).andDo(print()).andExpect(status().isCreated()); mockMvc.perform(get("/bookings/" + dateString2 + "/2")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString("MyTestActivity"))) .andExpect(content().string(containsString("0815"))) .andExpect(content().string(containsString("TestUser"))) .andExpect(content().string(containsString("Test Comment"))) .andExpect(content().string(containsString("starttime"))) .andExpect(content().string(containsString("endtime"))); mockMvc.perform(get("/bookings")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString(dateString))) .andExpect(content().string(containsString(dateString2))); mockMvc.perform(delete("/bookings/" + dateString + "/1")).andDo(print()).andExpect(status().isOk()); mockMvc.perform(delete("/bookings/" + dateString2 + "/2")).andDo(print()).andExpect(status().isOk()); mockMvc.perform(get("/bookings")).andDo(print()).andExpect(status().isOk()) .andExpect(content().string(containsString("[]"))); }
From source file:pl.java.scalatech.domain.User.java
public static Predicate<User> isAnAdult() { return isOlderThanOrEqual(LocalDate.now().minus(18, ChronoUnit.YEARS)); }
From source file:de.jfachwert.rechnung.Rechnungsmonat.java
/** * Der Default-Konstruktor legt einen Rechnungsmonat vom aktuellen Monat * an. */ public Rechnungsmonat() { this(LocalDate.now()); }
From source file:io.curly.artifact.ArtifactoryApplication.java
@Bean CommandLineRunner commandLineRunner(MongoTemplate mongoTemplate) { return args -> { Artifact artifact = new Artifact(); Set<Language> languages = new HashSet<>(0); Set<Tag> tags = new HashSet<>(0); tags.add(new Tag("document")); tags.add(new Tag("nosql")); languages.add(new Language("java")); languages.add(new Language("groovy")); languages.add(new Language("ruby")); languages.add(new Language("scala")); languages.add(new Language("javascript")); artifact.setName("curly"); artifact.setDescription("a hobby project"); artifact.setAuthor("joaoevangelista"); artifact.setCategory(new Category("database")); artifact.setHomePage("http://example.com"); artifact.setIncubation(LocalDate.now().toString()); artifact.setLanguages(languages); artifact.setTags(tags);//from www. j ava2 s. c o m artifact.setOwner("6969"); mongoTemplate.save(artifact); }; }