List of usage examples for java.time LocalDate of
public static LocalDate of(int year, int month, int dayOfMonth)
From source file:de.steilerdev.myVerein.server.controller.init.InitController.java
License:asdf
/** * This function is clearing the current database and creates a new set of test data. This function is called by POSTing the URI '/' * @return In general it should just return okay. No error checking is done! *///from w w w.j a v a2 s . c om @RequestMapping(value = "database", method = RequestMethod.POST) public ResponseEntity<String> createDatabaseExample() { logger.debug("Deleting old database and reloading database example."); resetDatabase(); User user1 = new User("Frank", "Steiler", "frank@steiler.eu", "asdf"); user1.setBirthday(LocalDate.of(1994, 6, 28)); user1.setActiveSince(LocalDate.of(2000, 1, 1)); user1.setIban("DE46500700100927353010"); user1.setBic("BYLADEM1001"); user1.setCity("Stuttgart"); user1.setZipCode("70190"); user1.setStreetNumber("27"); user1.setStreet("Metzstrae"); user1.setCountry("Germany"); user1.setGender(User.Gender.MALE); User user2 = new User("John", "Doe", "john@doe.com", "asdf"); user2.setActiveSince(LocalDate.of(1999, 1, 1)); user2.setPassiveSince(LocalDate.of(2000, 6, 1)); User user3 = new User("Peter", "Enis", "peter@enis.com", "asdf"); User user4 = new User("Luke", "Skywalker", "luke@skywalker.com", "asdf"); user4.setGender(User.Gender.MALE); User user5 = new User("Marty", "McFly", "marty@mcfly.com", "asdf"); User user6 = new User("Tammo", "Schwindt", "tammo@tammon.de", "asdf"); userRepository.save(user1); userRepository.save(user2); userRepository.save(user3); userRepository.save(user4); userRepository.save(user5); userRepository.save(user6); Division div1 = new Division("myVerein", null, user1, null); Division div2 = new Division("Rugby", null, user2, div1); Division div3 = new Division("Soccer", null, null, div1); Division div4 = new Division("Rugby - 1st team", null, user2, div2); Division div5 = new Division("Rugby - 2nd team", null, user3, div2); divisionRepository.save(div1); divisionRepository.save(div2); divisionRepository.save(div3); divisionRepository.save(div4); divisionRepository.save(div5); int thisMonth = LocalDateTime.now().getMonthValue(); int thisYear = LocalDateTime.now().getYear(); Event event1 = new Event(); event1.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 13, 0)); event1.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 14, 0)); event1.setName("Super Event 1"); event1.setLocation("DHBW Stuttgart"); event1.setLocationLat(48.7735272); event1.setLocationLng(9.171102399999995); event1.setDescription("Super event at awesome location with great people"); event1.addDivision(div2); event1.setEventAdmin(user1); event1.updateMultiDate(); event1.setLastChanged(LocalDateTime.now()); Event event2 = new Event(); event2.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 20, 13, 0)); event2.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 0)); event2.setName("Super Event 2"); event2.addDivision(div3); event2.setEventAdmin(user4); event2.updateMultiDate(); event2.setLastChanged(LocalDateTime.now()); Event event3 = new Event(); event3.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 0)); event3.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 21, 13, 5)); event3.setName("Super Event 3"); event3.addDivision(div1); event3.setEventAdmin(user1); event3.updateMultiDate(); event3.setLastChanged(LocalDateTime.now()); Event event4 = new Event(); event4.setStartDateTime(LocalDateTime.of(thisYear, thisMonth, 11, 13, 0)); event4.setEndDateTime(LocalDateTime.of(thisYear, thisMonth, 15, 13, 5)); event4.setName("Super Event 4"); event4.addDivision(div1); event4.setEventAdmin(user2); event4.updateMultiDate(); event4.setLastChanged(LocalDateTime.now()); eventRepository.save(event1); eventRepository.save(event2); eventRepository.save(event3); eventRepository.save(event4); user1.replaceDivisions(divisionRepository, eventRepository, div1); user2.replaceDivisions(divisionRepository, eventRepository, div2, div4); user3.replaceDivisions(divisionRepository, eventRepository, div2); user4.replaceDivisions(divisionRepository, eventRepository, div3); user5.replaceDivisions(divisionRepository, eventRepository, div2, div4); userRepository.save(user1); userRepository.save(user2); userRepository.save(user3); userRepository.save(user4); userRepository.save(user5); Message message1 = new Message("Hello world", user1, divisionRepository.findById(div1.getId())); Message message2 = new Message("Hello world, too", user2, divisionRepository.findById(div1.getId())); messageRepository.save(message1); messageRepository.save(message2); Settings systemSettings = new Settings(); systemSettings.setClubName("myVerein"); List<String> customUserFields = new ArrayList<>(); customUserFields.add("Membership number"); systemSettings.setCustomUserFields(customUserFields); settingsRepository.save(systemSettings); return new ResponseEntity<>("Successfully reset database to example", HttpStatus.OK); }
From source file:cz.muni.fi.pv168.project.hotelmanager.TestReservationManagerImpl.java
@Test public void TestFindRoomWithGuest() { LocalDate checkin = LocalDate.of(2016, 8, 7); LocalDate checkout = LocalDate.of(2016, 8, 11); LocalDate reservationdate = LocalDate.now(prepareClockMock(now)); Room room1 = setRoom(101, 2, 125, true); Room room2 = setRoom(102, 3, 250, false); roomManager.createRoom(room1);/*from www . j av a2 s . c o m*/ roomManager.createRoom(room2); Guest guest1 = setGuest("Oleg Bezpalko", "Zagorska", "75899654", "Oleg999@mail"); Guest guest2 = setGuest("Bogdan Voedylo", "Sobranetska", "78965452", "Myro777@mail"); guestManager.createGuest(guest1); guestManager.createGuest(guest2); reservationManager.assignRoomToGuest(guest1, room2, checkin, checkout); reservationManager.assignRoomToGuest(guest2, room1, checkin, checkout); List<Room> roomf1 = reservationManager.findRoomWithGuest(guest2); assertThat("wrong size or rooms found", roomf1.size(), is(equalTo(1))); assertDeepEquals(roomf1.get(0), room1); List<Room> roomf2 = reservationManager.findRoomWithGuest(guest1); assertThat("wrong size or rooms found", roomf2.size(), is(equalTo(1))); assertDeepEquals(roomf2.get(0), room2); Room room3 = setRoom(103, 3, 250, false); roomManager.createRoom(room3); reservationManager.assignRoomToGuest(guest1, room3, checkin, checkout); List<Room> roomf3 = reservationManager.findRoomWithGuest(guest1); assertThat("wrong size or rooms found", roomf3.size(), is(equalTo(2))); }
From source file:Pages.LandingPage.java
private LocalDate stringToDate(String strDate) { String[] nums = strDate.split("/"); return LocalDate.of(Integer.parseInt(nums[2]), Integer.parseInt(nums[1]), Integer.parseInt(nums[0])); }
From source file:net.resheim.eclipse.timekeeper.ui.views.WorkWeekView.java
@Override public void createPartControl(Composite parent) { FormToolkit ft = new FormToolkit(parent.getDisplay()); ScrolledComposite root = new ScrolledComposite(parent, SWT.V_SCROLL); ft.adapt(root);//from w w w. ja va2s . co m GridLayout layout = new GridLayout(); root.setLayout(layout); root.setExpandHorizontal(true); root.setExpandVertical(true); Composite main = ft.createComposite(root); ft.adapt(main); root.setContent(main); GridLayout layout2 = new GridLayout(3, false); layout2.horizontalSpacing = 0; main.setLayout(layout2); dateTimeLabel = new Text(main, SWT.NONE); GridData gdLabel = new GridData(); gdLabel.verticalIndent = 3; gdLabel.verticalAlignment = SWT.BEGINNING; dateTimeLabel.setLayoutData(gdLabel); dateChooser = new DateTime(main, SWT.DROP_DOWN | SWT.DATE | SWT.LONG); GridData gdChooser = new GridData(); gdChooser.verticalAlignment = SWT.BEGINNING; dateChooser.setLayoutData(gdChooser); ft.adapt(dateChooser); dateChooser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // Determine the first date of the week LocalDate date = LocalDate.of(dateChooser.getYear(), dateChooser.getMonth() + 1, dateChooser.getDay()); contentProvider.setFirstDayOfWeek(calculateFirstDayOfWeek(date)); viewer.setInput(this); } }); statusLabel = new Text(main, SWT.NONE); GridData gdStatusLabel = new GridData(); gdStatusLabel.grabExcessHorizontalSpace = true; gdStatusLabel.horizontalAlignment = SWT.FILL; gdStatusLabel.verticalIndent = 3; gdStatusLabel.verticalAlignment = SWT.BEGINNING; statusLabel.setLayoutData(gdStatusLabel); viewer = new TreeViewer(main, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION); // Make the tree view provide selections getSite().setSelectionProvider(viewer); contentProvider = new ViewContentProvider(); viewer.setContentProvider(contentProvider); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.horizontalSpan = 3; viewer.getControl().setLayoutData(layoutData); createTitleColumn(); for (int i = 0; i < 7; i++) { createTimeColumn(i); } Tree tree = viewer.getTree(); viewer.setComparator(new ViewerComparatorExtension()); tree.setHeaderVisible(true); tree.setLinesVisible(true); // Adjust column width when view is resized root.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle area = root.getClientArea(); int width = area.width - 2 * tree.getBorderWidth(); Point vBarSize = tree.getVerticalBar().getSize(); width -= vBarSize.x; TreeColumn[] columns = tree.getColumns(); int cwidth = 0; for (int i = 1; i < columns.length; i++) { columns[i].pack(); if (columns[i].getWidth() < 50) { columns[i].setWidth(50); } cwidth += columns[i].getWidth(); } tree.getColumns()[0].setWidth(width - cwidth); } }); // Determine the first date of the week LocalDate date = LocalDate.now(); WeekFields weekFields = WeekFields.of(Locale.getDefault()); int day = date.get(weekFields.dayOfWeek()); contentProvider.setFirstDayOfWeek(date.minusDays(day - 1)); makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); taskListener = new TaskListener(); TasksUiPlugin.getTaskActivityManager().addActivationListener(taskListener); TasksUiPlugin.getTaskList().addChangeListener(taskListener); viewer.setInput(getViewSite()); // Force a redraw so content is visible root.pack(); installStatusUpdater(); }
From source file:com.gnadenheimer.mg3.utils.Utils.java
public static LocalDate inicioPeriodoFiscal() { return LocalDate.of(App.periodoFiscal, Month.JANUARY, 1); }
From source file:com.gnadenheimer.mg3.utils.Utils.java
public static LocalDate finPeriodoFiscal() { return LocalDate.of(App.periodoFiscal, Month.DECEMBER, 31); }
From source file:ui.Analyze.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed new Thread(() -> { LocalDate ld1 = LocalDate.of(Integer.parseInt("" + thnAwal.getValue()), Integer.parseInt("" + blnAwal.getValue()), Integer.parseInt("" + tglAwal.getValue())), ld2 = LocalDate.of(Integer.parseInt("" + thnAkhir.getValue()), Integer.parseInt("" + blnAkhir.getValue()), Integer.parseInt("" + tglAkhir.getValue())); try {//from w w w .j a v a 2s .c o m genaratePermintaan(ld1, ld2); } catch (SQLException ex) { util.Db.hindar(ex); } this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); }).start(); this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR)); }
From source file:ui.Analyze.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed new Thread(() -> { LocalDate ld1 = LocalDate.of(Integer.parseInt("" + thnAwalUR.getValue()), Integer.parseInt("" + blnAwalUR.getValue()), Integer.parseInt("" + tglAwalUR.getValue())), ld2 = LocalDate.of(Integer.parseInt("" + thnAkhirUR.getValue()), Integer.parseInt("" + blnAkhirUR.getValue()), Integer.parseInt("" + tglAkhirUR.getValue())); try {/*from w ww.ja v a2 s . c o m*/ generateUR(ld1, ld2); } catch (SQLException ex) { util.Db.hindar(ex); } this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); }).start(); this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR)); }
From source file:ui.Analyze.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed new Thread(() -> { LocalDate ld1 = LocalDate.of(Integer.parseInt("" + thnAwalLaba.getValue()), Integer.parseInt("" + blnAwalLaba.getValue()), Integer.parseInt("" + tglAwalLaba.getValue())), ld2 = LocalDate.of(Integer.parseInt("" + thnAkhirLaba.getValue()), Integer.parseInt("" + blnAkhirLaba.getValue()), Integer.parseInt("" + tglAkhirLaba.getValue())); try {/*from ww w . jav a2 s.c o m*/ generateLaba(ld1, ld2); } catch (SQLException ex) { util.Db.hindar(ex); } this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); }).start(); this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR)); }
From source file:org.silverpeas.core.calendar.CalendarEventOccurrenceGenerationTest.java
private static LocalDate date(int year, int month, int day) { return LocalDate.of(year, month, day); }