List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:com.swcguild.capstoneproject.dao.BlogDaoDbImplTest.java
/** * Test of publishPinPost method, of class BlogDaoDbImpl. *///from ww w . j av a2s .com @Test public void testPublishPinPost() { System.out.println("publishPinPost"); List<PinPost> expresult = new ArrayList<>(); PinPost pinPost1 = new PinPost("Cali1", "Shawn", "Won by 14", LocalDateTime.now().toString(), "2016-01-01"); expresult.add(pinPost1); PinPost pinPost2 = new PinPost("Cali2", "Shawn", "Won by 14", LocalDateTime.now().toString(), "2016-01-01"); expresult.add(pinPost2); PinPost pinPost3 = new PinPost("Cali3", "Shawn", "Won by 14", LocalDateTime.now().toString(), "2016-01-01"); expresult.add(pinPost3); }
From source file:com.ccserver.digital.controller.AdminControllerTest.java
@Test public void approveApplicationTest() { // Arrange//from ww w. jav a 2s . co m Long id = 1l; CreditCardApplicationDTO app = new CreditCardApplicationDTO(); app.setId(id); app.setSubmittedLos(LocalDateTime.now()); app.setStatus(Status.Processing); Mockito.when(ccAppService.approveApplication(id)).thenReturn(app); // Act ResponseEntity<?> response = controller.approveApplication(id); // Assert Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); Assert.assertEquals(app, response.getBody()); }
From source file:com.gnadenheimer.mg.utils.Utils.java
public Boolean exectueBackUp(String backupDirectory) { try {/*from w w w. j a v a2 s . c o m*/ //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); //String backupfile = backupDirectory + "\\BackUp_" + sdf.format(new LocalDateTime()); String backupfile = backupDirectory + "\\BackUp_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss")); Connection conn = getDatabaseConnection(); try (CallableStatement cs = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_BACKUP_DATABASE(?)")) { cs.setString(1, backupfile); cs.execute(); cs.close(); } catch (Exception ex) { LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); JOptionPane.showMessageDialog(null, Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage()); } JOptionPane.showMessageDialog(null, "BackUp guardado con exito en: " + backupfile); return true; } catch (Exception ex) { LOGGER.error(Thread.currentThread().getStackTrace()[1].getMethodName(), ex); JOptionPane.showMessageDialog(null, Thread.currentThread().getStackTrace()[1].getMethodName() + " - " + ex.getMessage()); return false; } }
From source file:kitt.site.controller.mobile.UserController.java
/** * ?-??/*w w w .j a v a 2s . com*/ * @param code ?? * @param password ? * @param phone ? * @param bindResult */ @ResponseBody @RequestMapping(value = "/account/resetForgetPassword", method = RequestMethod.POST) public Object resetForgetPassword(String code, String password, String phone, BindResult bindResult) { Phonevalidator phonevalidator = validMapper.findVerifyCode(phone, code, ValidateType.forgetPasswordWeixin); User user = userMapper.getUserByPhone(phone); if (user == null) { bindResult.addError("userIsNotExists", "?!"); } else if (!user.isIsactive()) { bindResult.addError("userorbidden", "?!"); } else if (StringUtils.isBlank(code)) { bindResult.addError("verifyCode", "???!"); } else if (phonevalidator == null) { bindResult.addError("verifyCode", "??!"); } else if (phonevalidator.getExpiretime().isBefore(LocalDateTime.now())) { bindResult.addError("verifyCode", "??!"); } else { validMapper.modifyValidatedAndTime(user.getSecurephone(), code); userMapper.modifyPasswdByPhone(DigestUtils.md5Hex(password), user.getSecurephone()); } return json(bindResult); }
From source file:fr.landel.utils.assertor.OperatorTest.java
/** * Test method for {@link Operator#xor()}. */// w w w . j a v a 2 s . co m @Test public void testXor() { final String text = "text"; assertTrue(Assertor.that(text).isEmpty().xor().isNotBlank().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(true).isTrue().isOK()); assertFalse(Assertor.that(text).isEmpty().xor(true).isFalse().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(text.getClass()).isAssignableFrom(CharSequence.class).isOK()); assertFalse( Assertor.that(text).isEmpty().xor(text.getClass()).isAssignableFrom(StringBuilder.class).isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Calendar.getInstance()) .isAfter(DateUtils.getCalendar(new Date(0))).isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Calendar.getInstance()) .isBefore(DateUtils.getCalendar(new Date(0))).isOK()); assertTrue(Assertor.that(text).isEmpty().xor(new Date()).isAfter(new Date(0)).isOK()); assertFalse(Assertor.that(text).isEmpty().xor(new Date()).isBefore(new Date(0)).isOK()); assertTrue(Assertor.that(text).isNotEmpty().xor(LocalDateTime.now()).isAfter(LocalDateTime.MAX).isOK()); assertFalse(Assertor.that(text).isNotEmpty().xor(LocalDateTime.now()).isAfter(LocalDateTime.MIN).isOK()); assertTrue(Assertor.that(text).isEmpty().xor(2).isGT(1).isOK()); assertFalse(Assertor.that(text).isEmpty().xor(2).isLT(1).isOK()); assertTrue(Assertor.that(text).isEmpty().xor("tt").isNotEmpty().isOK()); assertFalse(Assertor.that(text).isEmpty().xor("tt").isEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(new String[] {}).isEmpty().isOK()); assertFalse(Assertor.that(text).isEmpty().xor(new String[] {}).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(new String[] {}, EnumAnalysisMode.STREAM).isEmpty().isOK()); assertFalse( Assertor.that(text).isEmpty().xor(new String[] {}, EnumAnalysisMode.STREAM).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(new String[] {}, EnumAnalysisMode.PARALLEL).isEmpty().isOK()); assertFalse( Assertor.that(text).isEmpty().xor(new String[] {}, EnumAnalysisMode.PARALLEL).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyList()).isEmpty().isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyList()).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyList(), EnumAnalysisMode.STREAM).isEmpty() .isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyList(), EnumAnalysisMode.STREAM).isNotEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyList(), EnumAnalysisMode.PARALLEL).isEmpty() .isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyList(), EnumAnalysisMode.PARALLEL) .isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyMap()).isEmpty().isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyMap()).isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyMap(), EnumAnalysisMode.STREAM).isEmpty() .isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyMap(), EnumAnalysisMode.STREAM).isNotEmpty() .isOK()); assertTrue(Assertor.that(text).isEmpty().xor(Collections.emptyMap(), EnumAnalysisMode.PARALLEL).isEmpty() .isOK()); assertFalse(Assertor.that(text).isEmpty().xor(Collections.emptyMap(), EnumAnalysisMode.PARALLEL) .isNotEmpty().isOK()); assertTrue(Assertor.that(text).isEmpty().xor((Object) 0).isNotNull().isOK()); assertFalse(Assertor.that(text).isEmpty().xor((Object) 0).isNull().isOK()); assertTrue(Assertor.that(text).isEmpty().xor(new Exception()).isNotNull().isOK()); assertFalse(Assertor.that(text).isEmpty().xor(new Exception()).isNull().isOK()); assertTrue(Assertor.that(Color.BLACK).isNull().xor().isEqual(Color.black).isOK()); assertTrue(Assertor.that(Color.BLACK).isNull().xor((Object) 0).isNotNull().isOK()); assertTrue(Assertor.that(Color.BLACK).isNotNull().xor(Assertor.that(text).isEmpty()).isOK()); // SUB ASSERTOR assertTrue(Assertor.that(text).isNotEmpty().xorAssertor(t -> Assertor.that(t.length()).isGT(4)).isOK()); assertEquals( "the char sequence 'text' should be null or empty XOR (the number '4' should be greater than '4')", Assertor.that(text).isEmpty().xorAssertor(t -> Assertor.that(t.length()).isGT(4)).getErrors() .get()); assertException( () -> Assertor.that(text).isNotEmpty() .xorAssertor((Function<String, StepCharSequence<String>>) null).isOK(), IllegalStateException.class, "sub assertor cannot be null"); // MAPPER assertTrue(Assertor.that(false).isTrue().xorObject(b -> b.toString()).hasHashCode(Objects.hashCode("false")) .isOK()); assertTrue(Assertor.that(false).isTrue().xorCharSequence(b -> b.toString()).contains("se").isOK()); assertTrue(Assertor.that("test").isNotEmpty() .xorArray(s -> ArrayUtils.toObject(s.getBytes(StandardCharsets.UTF_8))).contains((byte) 'x') .isOK()); assertTrue(Assertor.that(false).isTrue().xorBoolean(b -> b).isFalse().isOK()); assertTrue(Assertor.that(false).isTrue().xorClass(b -> b.getClass()).hasSimpleName("Boolean").isOK()); assertTrue(Assertor.that(false).isTrue().xorDate(b -> new Date(1464475553641L)) .isAfter(new Date(1464475553640L)).isOK()); assertTrue(Assertor.that(false).isTrue().xorCalendar(b -> DateUtils.getCalendar(new Date(1464475553641L))) .isBefore(Calendar.getInstance()).isOK()); assertTrue( Assertor.that(false).isTrue().xorTemporal(b -> DateUtils.getLocalDateTime(new Date(1464475553641L))) .isBefore(LocalDateTime.now()).isOK()); assertTrue(Assertor.that(false).isTrue().xorEnum(b -> EnumOperator.AND).hasName("AND").isOK()); assertTrue(Assertor.that(false).isTrue().xorIterable(b -> Arrays.asList('t', 'r')).contains('t').isOK()); assertTrue(Assertor.that(false).isTrue().xorMap(b -> MapUtils2.newHashMap("key", b)).contains("key", false) .isOK()); assertTrue(Assertor.that(false).isTrue().xorNumber(b -> b.hashCode()).isGT(0).isOK()); // 1231 assertTrue(Assertor.that(false).isTrue().xorThrowable(b -> new IOException(b.toString())) .validates(e -> e.getMessage().contains("false")).isOK()); }
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! *//*www . jav a 2 s . com*/ @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:br.ufc.deti.ecgweb.domain.exam.EcgService.java
@Transactional(timeout = 0) public void importEcg(Long patientId, File file, String ecgFileKey) throws IOException { System.out.println("Map Size=" + uploadFileMap.size()); EcgFileType type = EcgFileType.HL7;/*from w w w .j a va 2 s. c o m*/ lock.lock(); try { if (getUploadFile(patientId) != null) { //Has upload file occurring throw new ServiceUploadDuplicatedActionException(); } else { addUploadFile(patientId, file); } } finally { lock.unlock(); } System.out.println("Map Size=" + uploadFileMap.size()); AbstractEcgFormat hl7 = new HL7FormatImpl(); hl7.loadInformationFromFile(file); String newfileName = ecgFileKey; Patient patient = patientRepository.findOne(patientId); EcgFile ecgFile = new EcgFile(); ecgFile.setDate(LocalDateTime.now()); ecgFile.setFileName(newfileName); ecgFile.setType(type); ecgFileRepository.save(ecgFile); Ecg ecg = new Ecg(); ecg.setBaseLine(hl7.getBaseLine()); ecg.setGain(hl7.getGain()); ecg.setSampleRate(hl7.getSampleRate()); ecg.setFinished(Boolean.FALSE); ecg.setFile(ecgFile); ecgRepository.save(ecg); for (int i = 0; i < hl7.getNumberOfChannels(); i++) { EcgChannel channel = new EcgChannel(); channel.setLeadType(hl7.getChannelType(i)); long count = 0; List<EcgSignal> signals = hl7.getChannelSignals(i); for (EcgSignal signal : signals) { count++; /*if (count == 30000) { break; }*/ EcgSignal signal_ = new EcgSignal(); signal_.setSampleIdx(signal.getSampleIdx()); signal_.setyIntensity(signal.getyIntensity()); ecgSignalRepository.save(signal_); channel.addSignal(signal_); if (count % 10000 == 0) { System.out.println(patientId + " : signal:" + count); } } channel.setEcg(ecg); ecgChannelRepository.save(channel); ecg.addChannel(channel); ecgRepository.save(ecg); } patient.addEcgExam(ecg); patientRepository.save(patient); ecg.setFinished(Boolean.TRUE); ecgRepository.save(ecg); Path pathIn = FileSystems.getDefault().getPath(file.getAbsolutePath()); Path pathOut = FileSystems.getDefault().getPath("/home/ecgs/" + newfileName); Files.copy(pathIn, pathOut); Files.deleteIfExists(pathIn); lock.lock(); try { removeUploadFile(patientId); } finally { lock.unlock(); } System.out.println("Map Size=" + uploadFileMap.size()); }
From source file:net.resheim.eclipse.timekeeper.ui.Activator.java
private void installTaxameter() { switch (Platform.getOS()) { case Platform.OS_MACOSX: detector = new MacIdleTimeDetector(); break;/*from w w w. j a v a2 s . co m*/ case Platform.OS_LINUX: detector = new X11IdleTimeDetector(); break; case Platform.OS_WIN32: detector = new WindowsIdleTimeDetector(); break; default: detector = new GenericIdleTimeDetector(); break; } Timer timer = new Timer("Timekeeper", true); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (!PlatformUI.getWorkbench().isClosing()) { long idleTimeMillis = detector.getIdleTimeMillis(); ITask task = TasksUi.getTaskActivityManager().getActiveTask(); if (null != task) { if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) { // Was idle on last check, reactivate Display.getDefault().syncExec(() -> handleReactivation(idleTimeMillis)); } else if (lastIdleTime < IDLE_INTERVAL) { String tickString = Activator.getValue(task, Activator.TICK); LocalDateTime now = LocalDateTime.now(); LocalDateTime ticked = LocalDateTime.parse(tickString); // Currently not idle so accumulate spent time accumulateTime(task, now.toLocalDate().toString(), ticked.until(now, ChronoUnit.MILLIS)); Activator.setValue(task, Activator.TICK, now.toString()); } } lastIdleTime = idleTimeMillis; } } }, SHORT_INTERVAL, SHORT_INTERVAL); // Immediately run the idle handler if the system has been idle and // the user has pressed a key or mouse button _inside_ the running // application. reactivationListener = new Listener() { public void handleEvent(Event event) { long idleTimeMillis = detector.getIdleTimeMillis(); if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) { handleReactivation(idleTimeMillis); } lastIdleTime = idleTimeMillis; } }; final Display display = PlatformUI.getWorkbench().getDisplay(); display.addFilter(SWT.KeyUp, reactivationListener); display.addFilter(SWT.MouseUp, reactivationListener); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testAssignTicketToWaitingQueueUnboundedCategorySelected() { LocalDateTime start = LocalDateTime.now().minusHours(1); LocalDateTime end = LocalDateTime.now().plusHours(1); List<TicketCategoryModification> categories = Arrays.asList( new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null), new TicketCategoryModification(null, "default2", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();// ww w . j a v a 2s . co m List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); TicketCategory first = ticketCategories.get(0); TicketCategory second = ticketCategories.get(1); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(second.getId()); TicketReservationModification tr3 = new TicketReservationModification(); tr3.setAmount(1); tr3.setTicketCategoryId(first.getId()); reserveTickets(event, first, AVAILABLE_SEATS - 2); String reservationIdSingleFirst = reserveTickets(event, second, 1); String reservationIdSingleSecond = reserveTickets(event, second, 1); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue(waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", first.getId(), Locale.ENGLISH)); assertTrue(waitingQueueManager.subscribe(event, new CustomerName("John Doe 2", "John", "Doe 2", event), "john@doe2.com", second.getId(), Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleFirst, false); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleSecond, false); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(2, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(first.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); subscriptionDetail = subscriptions.get(1); assertEquals("john@doe2.com", subscriptionDetail.getLeft().getEmailAddress()); reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(second.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:org.talend.dataprep.transformation.actions.date.ComputeTimeSinceTest.java
/** * Compute time since ./*from w w w . j a v a 2 s .c o m*/ * * @param date the date to compute from. * @param pattern the pattern to use. * @param unit the unit for the result. * @param sinceWhen the date to calculate since when * @return time since now in the wanted unit. */ String computeTimeSince(String date, String pattern, ChronoUnit unit, String sinceWhen) { DateTimeFormatter format = DateTimeFormatter.ofPattern(pattern); Temporal since; if (sinceWhen == null) { since = LocalDateTime.now(); } else { since = LocalDateTime.parse(sinceWhen, format); } LocalDateTime start; try { start = LocalDateTime.parse(date, format); } catch (Exception e) { start = null; } if (start == null) { LocalDate temp = LocalDate.parse(date, format); start = temp.atStartOfDay(); } Temporal result = LocalDateTime.from(start); return String.valueOf(unit.between(result, since)); }