@Override @SuppressWarnings("InfiniteLoopStatement") public void run() { while (true) { Platform.runLater(() -> { calendarView.setToday(LocalDate.now()); calendarView.setTime(LocalTime.now()); }); try { sleep(TEN_SECONDS); } catch (InterruptedException e) { // Do nothing } } }
@DataProvider(name="atEndOfMonth") Object[][] data_atEndOfMonth() { return new Object[][] { {YearMonth.of(2008, 1), LocalDate.of(2008, 1, 31)}, {YearMonth.of(2008, 2), LocalDate.of(2008, 2, 29)}, {YearMonth.of(2008, 3), LocalDate.of(2008, 3, 31)}, {YearMonth.of(2008, 4), LocalDate.of(2008, 4, 30)}, {YearMonth.of(2008, 5), LocalDate.of(2008, 5, 31)}, {YearMonth.of(2008, 6), LocalDate.of(2008, 6, 30)}, {YearMonth.of(2008, 12), LocalDate.of(2008, 12, 31)}, {YearMonth.of(2009, 1), LocalDate.of(2009, 1, 31)}, {YearMonth.of(2009, 2), LocalDate.of(2009, 2, 28)}, {YearMonth.of(2009, 3), LocalDate.of(2009, 3, 31)}, {YearMonth.of(2009, 4), LocalDate.of(2009, 4, 30)}, {YearMonth.of(2009, 5), LocalDate.of(2009, 5, 31)}, {YearMonth.of(2009, 6), LocalDate.of(2009, 6, 30)}, {YearMonth.of(2009, 12), LocalDate.of(2009, 12, 31)}, }; }
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDate date2 = chrono2.date(refDate); TemporalField adjuster = new FixedTemporalField(date2); if (chrono != chrono2) { try { date.with(adjuster, 1); Assert.fail("TemporalField doSet should have thrown a ClassCastException" + date.getClass() + ", can not be cast to " + date2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDate result = date.with(adjuster, 1); assertEquals(result, date2, "TemporalField doSet failed to replace date"); } } }
@Test public void getText() { DatePicker datePicker = (DatePicker) getPrimaryStage().getScene().getRoot().lookup(".date-picker"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); RFXDatePicker rfxDatePicker = new RFXDatePicker(datePicker, null, null, lr); Platform.runLater(() -> { datePicker.setValue(LocalDate.now()); text.add(rfxDatePicker._getText()); }); new Wait("Waiting for date picker text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals(datePicker.getConverter().toString(LocalDate.now()), text.get(0)); }
@Test(dataProvider="calendars") public void test_badPlusAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAmount adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.plus(adjuster); Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: " + cdt2); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.plus(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date time"); } } }
/** * Creates and positions every node onto the GridPane for the given month and year. * Uses 7 (weekdays) columns and (max.) 6 rows (weeks). The rows and columns are created on fly or * are reused. * * @param monthPane The GradPane that is used for populating the DayNodes. * @param month The month that should be displayed. * @param year The year that should be displayed. */ private void populateMonthPane(GridPane monthPane, Month month, int year) { monthPane.getChildren().clear(); int currentRow = 0; for(LocalDate d = LocalDate.of(year, month, 1); d.getMonthValue() == month.getValue(); d = d.plusDays(1)) { Node dayNode = renderDayItem(d); final LocalDate currentDate = d; dayNode.setOnMouseClicked(event -> selectedDateProperty.set(currentDate)); int column = d.getDayOfWeek().getValue(); monthPane.add(dayNode, column, currentRow); if(column == 7) { currentRow++; } } }
@Override public List<SupervisionDetails> getSupervisionList() { List<SupervisionDetails> supervisionDetails = new ArrayList<>(); List<Tractor> tractorList = this.getAllTractors(); for(Tractor tractor : tractorList){ if(DateUtils.getDaysDifference(tractor.getDateOfSupervision(), LocalDate.now()) <= 30){ SupervisionDetails details = new SupervisionDetails(); details.setDateOfSupervision(tractor.getDateOfSupervision()); details.setDaysRemaining(DateUtils.getDaysDifference(tractor.getDateOfSupervision(),LocalDate.now())); details.setManufacturer(tractor.getManufacturer()); details.setType(tractor.getType()); details.setPlateNo(tractor.getPlateNumber()); supervisionDetails.add(details); } } logger.debug("in 30 days of supervision: {}",supervisionDetails.size()); return supervisionDetails; }
/** * {@link M5#instantOfNextFrame(Instant)} should return the instant with the minutes set to the earliest possible * {@link Instant} that is later than the {@link Instant} past and thats minutes are a multiple of 5. */ @Test public void m5InstantOfNextFrameShouldReturnTheNextInstantThatsMinutesAreAMultipleOfFive() { final M5 cut = new M5(); assertThat(cut.instantOfNextFrame(LocalDate.of(2074, Month.MARCH, 30).atTime(20, 4, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2074, Month.MARCH, 30).atTime(20, 5, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1999, Month.APRIL, 23).atTime(15, 59, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1999, Month.APRIL, 23).atTime(16, 0, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2007, Month.SEPTEMBER, 6).atTime(17, 29, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2007, Month.SEPTEMBER, 6).atTime(17, 30, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2021, Month.JUNE, 8).atTime(8, 34, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2021, Month.JUNE, 8).atTime(8, 35, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1570, Month.NOVEMBER, 24).atTime(23, 7, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1570, Month.NOVEMBER, 24).atTime(23, 10, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2047, Month.JANUARY, 24).atTime(16, 15, 0, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(2047, Month.JANUARY, 24).atTime(16, 20, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(1989, Month.JUNE, 10).atTime(15, 14, 37, 0).toInstant(UTC))) .isEqualTo(LocalDate.of(1989, Month.JUNE, 10).atTime(15, 15, 0, 0).toInstant(UTC)); assertThat(cut.instantOfNextFrame(LocalDate.of(2006, Month.AUGUST, 10).atTime(3, 29, 0, 7521).toInstant(UTC))) .isEqualTo(LocalDate.of(2006, Month.AUGUST, 10).atTime(3, 30, 0, 0).toInstant(UTC)); assertThat( cut.instantOfNextFrame(LocalDate.of(3057, Month.NOVEMBER, 10).atTime(8, 54, 12, 45720).toInstant(UTC))) .isEqualTo(LocalDate.of(3057, Month.NOVEMBER, 10).atTime(8, 55, 0, 0).toInstant(UTC)); }
@Test(dataProvider="weekFields") public void test_parse_resolve_localizedWoy(DayOfWeek firstDayOfWeek, int minDays) { LocalDate date = LocalDate.of(2012, 12, 15); WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField woyField = week.weekOfYear(); for (int i = 1; i <= 60; i++) { DateTimeFormatter f = new DateTimeFormatterBuilder() .appendValue(YEAR).appendLiteral(':') .appendValue(woyField).appendLiteral(':') .appendValue(DAY_OF_WEEK).toFormatter(); String str = date.getYear() + ":" + date.get(woyField) + ":" + date.get(DAY_OF_WEEK); LocalDate parsed = LocalDate.parse(str, f); assertEquals(parsed, date, " :: " + str + " " + i); date = date.plusDays(1); } }
/** * E.g. http://api.worldweatheronline.com/free/v2/search.ashx?query=oporto&format=tab&key=***** */ public Iterable<WeatherInfo> pastWeather( double lat, double log, LocalDate from, LocalDate to ) { String query = lat + "," + log; String path = WEATHER_HOST + WEATHER_PAST + String.format(WEATHER_PAST_ARGS, query, from, to, WEATHER_TOKEN); List<WeatherInfo> res = new ArrayList<>(); Iterator<String> iter = req.getContent(path).iterator(); while(iter.next().startsWith("#")) { } iter.next(); // Skip line: Not Available while(iter.hasNext()) { String line = iter.next(); // Skip Daily Info res.add(WeatherInfo.valueOf(line)); if(iter.hasNext()) iter.next(); } return res; }
@Test public void shouldSelectMultipleDates() { // Given LocalDate now = LocalDate.now(); LocalDate tomorrow = now.plusDays(1); LocalDate dayAfterTomorrow = tomorrow.plusDays(1); LocalDate oneYearAfter = dayAfterTomorrow.plusYears(1); DateSelectionModel model = new DateSelectionModel(); model.setSelectionMode(SelectionMode.MULTIPLE_DATES); // When model.selectRange(now, dayAfterTomorrow); model.select(oneYearAfter); // Then assertFalse(model.isEmpty()); assertThat(model.getSelectedDates(), is(not(empty()))); assertThat(model.getSelectedDates().size(), is(equalTo(4))); assertThat(model.getSelectedDates(), contains(now, tomorrow, dayAfterTomorrow, oneYearAfter)); assertThat(model.getLastSelected(), is(equalTo(oneYearAfter))); assertTrue(model.isSelected(now)); assertTrue(model.isSelected(tomorrow)); assertTrue(model.isSelected(dayAfterTomorrow)); assertTrue(model.isSelected(oneYearAfter)); }
@Test public void test_reducedWithLateChronoChange() { ThaiBuddhistDate date = ThaiBuddhistDate.of(2543, 1, 1); DateTimeFormatter df = new DateTimeFormatterBuilder() .appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) .appendLiteral(" ") .appendChronologyId() .toFormatter(); int expected = date.get(YEAR); String input = df.format(date); ParsePosition pos = new ParsePosition(0); TemporalAccessor parsed = df.parseUnresolved(input, pos); assertEquals(pos.getIndex(), input.length(), "Input not parsed completely"); assertEquals(pos.getErrorIndex(), -1, "Error index should be -1 (no-error)"); int actual = parsed.get(YEAR); assertEquals(actual, expected, String.format("Wrong date parsed, chrono: %s, input: %s", parsed.query(TemporalQueries.chronology()), input)); }
public void processShortages(String productRefNo) { LocalDate today = LocalDate.now(clock); CurrentStock currentStock = stockService.getCurrentStock(productRefNo); List<ShortageEntity> shortages = ShortageFinder.findShortages( today, confShortagePredictionDaysAhead, currentStock, productionDao.findFromTime(productRefNo, today.atStartOfDay()), demandDao.findFrom(today.atStartOfDay(), productRefNo) ); List<ShortageEntity> previous = shortageDao.getForProduct(productRefNo); if (shortages != null && !shortages.equals(previous)) { notificationService.alertPlanner(shortages); if (currentStock.getLocked() > 0 && shortages.get(0).getAtDay() .isBefore(today.plusDays(confIncreaseQATaskPriorityInDays))) { jiraService.increasePriorityFor(productRefNo); } } if (shortages.isEmpty() && !previous.isEmpty()) { shortageDao.delete(productRefNo); } }
public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) { // excludes type that are already produced by ConfigProducer Set<Class> types = injectionPoints.stream() .filter(ip -> ip.getType() instanceof Class && ip.getType() != String.class && ip.getType() != Boolean.class && ip.getType() != Boolean.TYPE && ip.getType() != Integer.class && ip.getType() != Integer.TYPE && ip.getType() != Long.class && ip.getType() != Long.TYPE && ip.getType() != Float.class && ip.getType() != Float.TYPE && ip.getType() != Double.class && ip.getType() != Double.TYPE && ip.getType() != Duration.class && ip.getType() != LocalDate.class && ip.getType() != LocalTime.class && ip.getType() != LocalDateTime.class) .map(ip -> (Class) ip.getType()) .collect(Collectors.toSet()); types.forEach(type -> abd.addBean(new ConfigInjectionBean(bm, type))); }
private static LocalDate parseLastRaceDate(List<ChartCharacter> chartCharacters) { ChartCharacter lastChartCharacter = null; List<ChartCharacter> lastRaceDateCharacters = new ArrayList<>(); for (ChartCharacter columnCharacter : chartCharacters) { // handle when lastChartCharacter race number is unknown if (columnCharacter.getFontSize() == 5 || spaceDetected(lastChartCharacter, columnCharacter)) { break; } lastRaceDateCharacters.add(columnCharacter); lastChartCharacter = columnCharacter; } String lastRaceDateText = Chart.convertToText(lastRaceDateCharacters); // so that 97 becomes 1997 and 03 becomes 2003 DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder() .appendPattern("dMMM") .appendValueReduced(ChronoField.YEAR_OF_ERA, 2, 2, LocalDate.now().minusYears(80)) .toFormatter(); LocalDate lastRaceDate = LocalDate.parse(lastRaceDateText, dateTimeFormatter); chartCharacters.removeAll(lastRaceDateCharacters); return lastRaceDate; }
private static boolean checkEquality(Map<LocalDate, ArrayList<Appointment>> data, Map<TimelessDate, ArrayList<BackportAppointment>> backportData) { if (data == null || backportData == null || data.size() != backportData.size()) { return false; } for (LocalDate dateKey : data.keySet()) { ArrayList<Appointment> list1 = data.get(dateKey); ArrayList<BackportAppointment> list2 = backportData.get(DateUtilities.ConvertToCalendar(dateKey)); if (list1 == null || list2 == null || list1.size() != list2.size()) { return false; } for (int i = 0; i < list1.size(); i++) { Appointment a1 = list1.get(i); BackportAppointment a2 = list2.get(i); if(!a1.getDate().equals(a2.getDate()) || !a1.getStartTime().equals(a2.getStartTime()) || !a1.getEndTime().equals(a2.getEndTime()) || !a1.getTitle().equals(a2.getTitle()) || !a1.getInfo().equals(a2.getInfo())) { return false; } } } return true; }
@Test public void test_firstDayOfYear_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.JANUARY); assertEquals(test.getDayOfMonth(), 1); } } }
@Test(dataProvider="sampleDates") public void test_get(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); assertEquals(a.getYear(), y); assertEquals(a.getMonth(), Month.of(m)); assertEquals(a.getDayOfMonth(), d); }
@Test public void lastOpeningDayClosedOnSaturday() throws Exception { assertThat(timeUtils.lastOpeningDay(LocalDate.of(2017, 6, 26), mensaClosedOnSaturday), equalTo(LocalDate.of(2017, 6, 26))); assertThat(timeUtils.lastOpeningDay(LocalDate.of(2017, 6, 25), mensaClosedOnSaturday), equalTo(LocalDate.of(2017, 6, 23))); assertThat(timeUtils.lastOpeningDay(LocalDate.of(2017, 6, 24), mensaClosedOnSaturday), equalTo(LocalDate.of(2017, 6, 23))); assertThat(timeUtils.lastOpeningDay(LocalDate.of(2017, 6, 23), mensaClosedOnSaturday), equalTo(LocalDate.of(2017, 6, 23))); assertThat(timeUtils.lastOpeningDay(LocalDate.of(2017, 5, 1), mensaClosedOnSaturday), equalTo(LocalDate.of(2017, 4, 28))); }
@Test public void testLazyFilterAndMapAndDistinct(){ WeatherWebApi api = new WeatherWebApi(new FileRequest()); Iterable<WeatherInfo> infos = api.pastWeather(41.15, -8.6167, LocalDate.of(2017,02,01),LocalDate.of(2017,02,28)); infos = filter(infos, info -> info.getDescription().toLowerCase().contains("sun")); Iterable<Integer> temps = map(infos, info -> info.getTempC()); // temps = map(infos, WeatherInfo::getTempC); temps = distinct(temps); assertEquals(5, count(temps)); assertEquals((long) 21, (long) skip(temps, 2).iterator().next()); temps.forEach(System.out::println); }
/** * プロシージャのリトライ */ @Test public void testProcedureRetryNoWait() throws Exception { int retryCount = 3; config.getSqlFilterManager().addSqlFilter(new RetrySqlFilter(retryCount, 60)); Procedure proc = agent.proc("example/insert_product_regist_work").param("product_name", "test") .param("product_kana_name", "test_kana").param("jan_code", "1234567890123") .param("product_description", "").param("ins_datetime", LocalDate.now()).retry(retryCount + 1); proc.call(); assertThat(proc.context().contextAttrs().get("__retryCount"), is(retryCount)); }
public void input2() { // tag::input2[] Input<LocalDate> dateInput = Components.input.localDate().caption("Date input").lenient(true).build(); // <1> Component inputComponent = dateInput.getComponent(); // <2> // end::input2[] }
@Override protected void deriveDependencies() { dependenciesJob = ElasticsearchDependenciesJob.builder() .nodes("http://" + elasticsearch.getContainerIpAddress() + ":" + elasticsearch .getMappedPort(9200)) .day(LocalDate.now()) .build(); dependenciesJob.run(); }
public Menu getNext(@NotNull LocalDate current) { Query query = em.createQuery("select m from Menu m where (m.date > :current) order by m.date ASC "); query.setParameter("current", current); query.setMaxResults(1); List list = query.getResultList(); if (list.isEmpty()) { return null; } else { return (Menu) list.get(0); } }
@Override public LocalDate decode( BsonReader reader, DecoderContext decoderContext) { return ofEpochMilli(reader.readDateTime()) .atOffset(UTC) .toLocalDate(); }
public static boolean is2016ParxOaksDebacle(Track track, LocalDate raceDate, Integer raceNumber) { return (track != null && track.getCode() != null && raceDate != null && raceNumber != null && track.getCode().equals("PRX") && raceDate.isEqual(LocalDate.of(2016, 5, 7)) && raceNumber == 8); }
@Override public LocalDate fromString(final String value) { if (value == null) { return null; } return Instant.ofEpochMilli(Long.parseLong(value)).atZone(DateUtils.getApplicationTimeZone().toZoneId()).toLocalDate(); }
private boolean isGeldigeKalendarDatum() { try { if (isJaarOnbekend || isMaandOnbekend) { return true; } else if (isDagOnbekend) { YearMonth.parse(jaar + maand, FORMATTER_JAAR_MND); } else { LocalDate.parse(jaar + maand + dag, DateTimeFormatter.BASIC_ISO_DATE); } } catch (final DateTimeException e) { LOG.trace("Fout bij het parsen van datum " + this, e); return false; } return true; }
@Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); if (test.getYear() == 2007) { int dayDiff = test.getDayOfYear() - date.getDayOfYear(); assertTrue(dayDiff <= 0 && dayDiff > -7); assertEquals(date.equals(test), date.getDayOfWeek() == dow); } else { assertFalse(date.getDayOfWeek() == dow); assertSame(month, Month.JANUARY); assertTrue(date.getDayOfMonth() < 7); assertEquals(test.getYear(), 2006); assertSame(test.getMonth(), Month.DECEMBER); assertTrue(test.getDayOfMonth() > 25); } } } } }
/** * JDBC 4.2 Helper methods. */ static Object convertJavaTimeToJavaSql(Object x) { if (x instanceof LocalDate) { return Date.valueOf((LocalDate) x); } else if (x instanceof LocalDateTime) { return Timestamp.valueOf((LocalDateTime) x); } else if (x instanceof LocalTime) { return Time.valueOf((LocalTime) x); } return x; }
public LocalDate getBaseEntityValueAsLocalDate(final String baseEntityCode, final String attributeCode) { BaseEntity be = getBaseEntityByCode(baseEntityCode); Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode); if (ea.isPresent()) { return ea.get().getValueDate(); } else { return null; } }
@Test public void test_resolverFields_selectOneDateResolveYMD() throws Exception { DateTimeFormatter base = new DateTimeFormatterBuilder() .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-') .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter(); DateTimeFormatter f = base.withResolverFields(YEAR, MONTH_OF_YEAR, DAY_OF_MONTH); try { base.parse("2012-6-30-321", LocalDate::from); // wrong day-of-year fail(); } catch (DateTimeException ex) { // expected, fails as it produces two different dates } LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored day-of-year assertEquals(parsed, LocalDate.of(2012, 6, 30)); }
private static void bepaalGemist(Collection<SelectieTaakDTO> taken) { for (SelectieTaakDTO taak : taken) { LocalDate datumPlanning = Optional.ofNullable(taak.getDatumPlanning()).orElse(taak.getBerekendeSelectieDatum()); SelectietaakStatus status = SelectietaakStatus.parseId((int) taak.getStatus()); if ((datumPlanning.isBefore(LocalDate.now()) && SelectieTaakServiceUtil.STATUS_ONVERWERKT.contains(status)) || SelectieTaakServiceUtil.STATUS_FOUTIEF.contains(status)) { taak.setOpnieuwPlannen(true); } } }
@Test(dataProvider="samples") public void test_samples_parse_STRICT(TemporalField field, LocalDate date, long value) { DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) .toFormatter().withResolverStyle(ResolverStyle.STRICT); LocalDate parsed = LocalDate.parse(Long.toString(value), f); assertEquals(parsed, date); }
@Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 if (expected >= 0) { assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); } else { assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); } }
@Test @UseDataProvider("validDates") public void formatsRestrictedNominalPublicationDate(final LocalDate referenceDate) throws Exception { final RestrictableDate restrictableDate = RestrictableDate.restrictedDateFrom(referenceDate); final String expectedFormattedDate = referenceDate.getMonth().getDisplayName(TextStyle.SHORT, Locale.UK) + " " + referenceDate.getYear(); testRestrictableDateFormatting(restrictableDate, expectedFormattedDate); }
/** * Constructs a new detailed date cell. * * @param view the parent month sheet view * @param date the date shown by the cell (might be null for leading or trailing empty cells) */ public DetailedDateCell(MonthSheetView view, LocalDate date) { super(view, date); canvas = new DetailCanvas(); canvas.setMouseTransparent(true); getChildren().add(canvas); }
@Test(dataProvider = "parallel") public void testColumnPredicate(boolean parallel) throws Exception { final String[] columns = {"Date", "Close", "Volume"}; final DataFrame<Integer,String> frame = DataFrame.read().csv(options -> { options.setResource("/csv/aapl.csv"); options.setIncludeColumns(columns); options.setParallel(parallel); options.getFormats().setParser("Volume", Long.class); }); final DataFrame<Integer,String> expected = DataFrame.read().csv(options -> { options.setResource("/csv/aapl.csv"); options.getFormats().setParser("Volume", Long.class); }); assertEquals(frame.rowCount(), 8503); assertEquals(frame.cols().count(), 3); assertTrue(frame.cols().keys().allMatch(Predicates.in(columns))); assertEquals(frame.cols().type("Date"), LocalDate.class); assertEquals(frame.cols().type("Close"), Double.class); assertEquals(frame.cols().type("Volume"), Long.class); frame.rows().forEach(row -> { for (String column : columns) { final Object actual = row.getValue(column); final Object expect = expected.data().getValue(row.key(), column); assertEquals(actual, expect, "The values match for " + row.key() + ", " + column); } }); }
@Test public void getAllItemsWithPrefixedLocationShouldReturnListOfItemsWhereTheLocationIsPrefixed() { ItemRepository itemRepository = mock(ItemRepository.class); ItemService itemService = new ItemService(itemRepository); String prefix = "==> "; Item item = new Item("Tasse", "Regal A", LocalDate.now()); List<Item> items = Arrays.asList(item); when(itemRepository.findAll()).thenReturn(items); assertThat(itemService.getAllItemsWithPrefixedLocation(prefix).get(0).getLocation(), is(prefix + "Regal A")); }
public static String printTimeIfSameDay(LocalDateTime dateAndTime) { if (dateAndTime.toLocalDate().isEqual(LocalDate.now())) { return dateAndTime.toLocalTime().format(timePrintFormatter); } else { return printDateTime(dateAndTime); } }