List of usage examples for java.time LocalDateTime toLocalTime
@Override
public LocalTime toLocalTime()
From source file:Main.java
public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01); System.out.println(a.toLocalTime()); }
From source file:daylightchart.daylightchart.calculation.RiseSetUtility.java
/** * Splits the given rise/ set at midnight. * * @param riseSet// www. ja v a 2 s .co m * Rise/ set to split * @return Split RiseSet(s) */ static RiseSet[] splitAtMidnight(final RiseSet riseSet) { if (riseSet == null) { return new RiseSet[0]; } final LocalDateTime sunrise = riseSet.getSunrise(); final LocalDateTime sunset = riseSet.getSunset(); if (riseSet.getRiseSetType() != RiseSetType.partial && sunset.getHour() < 9) { return new RiseSet[] { riseSet.withNewRiseSetTimes(sunrise.toLocalTime(), RiseSet.JUST_BEFORE_MIDNIGHT), riseSet.withNewRiseSetTimes(RiseSet.JUST_AFTER_MIDNIGHT, sunset.toLocalTime()) }; } else if (riseSet.getRiseSetType() != RiseSetType.partial && sunrise.getHour() > 15) { return new RiseSet[] { riseSet.withNewRiseSetTimes(RiseSet.JUST_AFTER_MIDNIGHT, sunset.toLocalTime()), riseSet.withNewRiseSetTimes(sunrise.toLocalTime(), RiseSet.JUST_BEFORE_MIDNIGHT) }; } else { return new RiseSet[] { riseSet }; } }
From source file:alfio.test.util.IntegrationTestUtil.java
public static Pair<Event, String> initEvent(List<TicketCategoryModification> categories, OrganizationRepository organizationRepository, UserManager userManager, EventManager eventManager, EventRepository eventRepository) { String organizationName = UUID.randomUUID().toString(); String username = UUID.randomUUID().toString(); String eventName = UUID.randomUUID().toString(); userManager.createOrganization(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); userManager.insertUser(organization.getId(), username + "_owner", "test", "test", "test@example.com", Role.OWNER, User.Type.INTERNAL); LocalDateTime expiration = LocalDateTime.now().plusDays(5).plusHours(1); 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", "url", null, eventName, "event display name", organization.getId(), "muh location", "0.0", "0.0", ZoneId.systemDefault().getId(), desc, new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), new DateTimeModification(expiration.toLocalDate(), expiration.toLocalTime()), BigDecimal.TEN, "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, Collections.singletonList(PaymentProxy.OFFLINE), categories, false, new LocationDescriptor("", "", "", ""), 7, null, null); eventManager.createEvent(em);/*from w ww .ja v a 2 s . c om*/ Event event = eventManager.getSingleEvent(eventName, username); Assert.assertEquals(AVAILABLE_SEATS, eventRepository.countExistingTickets(event.getId()).intValue()); return Pair.of(event, username); }
From source file:com.bdb.weather.display.day.DayWindPane.java
@Override protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) { plot.clearAnnotations();/*from www.j a v a 2 s . c o m*/ if (summaryRecord == null) return; LocalDateTime maxSpeedTime = summaryRecord.getMaxWindSpeedTime(); if (maxSpeedTime != null) { double maxSpeed = summaryRecord.getMaxWindSpeed().get(); String maxSpeedAnnotation = Speed.getDefaultFormatter().format(maxSpeed) + Speed.getDefaultUnit() + " " + DisplayConstants.formatTime(maxSpeedTime.toLocalTime()); XYTextAnnotation a = new XYTextAnnotation(maxSpeedAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxSpeedTime), maxSpeed); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.addAnnotation(a); } }
From source file:com.bdb.weather.display.day.DayPressurePane.java
@Override protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) { plot.getRenderer(0).removeAnnotations(); plot.getRenderer(1).removeAnnotations(); if (summaryRecord == null) return;/*w ww. j av a2 s . c om*/ LocalDateTime maxTime = summaryRecord.getMaxBaroPressureTime(); Pressure maxBaroPressure = summaryRecord.getMaxBaroPressure(); LocalDateTime minTime = summaryRecord.getMinBaroPressureTime(); Pressure minBaroPressure = summaryRecord.getMinBaroPressure(); // // Barometric pressure // String highAnnotation = maxBaroPressure.toString() + Pressure.getDefaultUnit() + " " + DisplayConstants.formatTime(maxTime.toLocalTime()); String lowAnnotation = minBaroPressure.toString() + Pressure.getDefaultUnit() + " " + DisplayConstants.formatTime(minTime.toLocalTime()); XYTextAnnotation a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxTime), maxBaroPressure.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.getRenderer(0).addAnnotation(a); TextAnchor anchor = TextAnchor.TOP_CENTER; if (minTime.getHour() <= 2) anchor = TextAnchor.TOP_LEFT; else if (minTime.getHour() >= 22) anchor = TextAnchor.TOP_RIGHT; a = new XYTextAnnotation(lowAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(minTime), minBaroPressure.get()); a.setTextAnchor(anchor); plot.getRenderer(0).addAnnotation(a); SolarRadiation maxSolarRadiation = summaryRecord.getMaxSolarRadiation(); maxTime = summaryRecord.getMaxSolarRadiationTime(); if (maxSolarRadiation != null) { highAnnotation = maxSolarRadiation.toString() + SolarRadiation.Unit.WATTS_PER_METER_SQUARED + " " + DisplayConstants.formatTime(maxTime.toLocalTime()); a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxTime), maxSolarRadiation.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.getRenderer(1).addAnnotation(a); } }
From source file:org.thevortex.lighting.jinks.robot.Recurrence.java
/** * Get the next occurrence from a time.//from w w w . j a v a2 s . c o m * * @param fromWhen when * @return the next occurrence or {@code null} if there is no more */ public LocalDateTime nextOccurrence(TemporalAccessor fromWhen) { LocalDateTime from = LocalDateTime.from(fromWhen); // if it's not today, try the next day if (frequency == Frequency.WEEKLY && !days.contains(from.getDayOfWeek())) { return nextOccurrence(from.plusDays(1).truncatedTo(ChronoUnit.DAYS)); } // if we've already started, it's too late - next day if (from.toLocalTime().isAfter(startTime)) { return nextOccurrence(from.plusDays(1).truncatedTo(ChronoUnit.DAYS)); } // otherwise, we're on the right day, so just adjust the time return from.with(startTime).truncatedTo(ChronoUnit.MINUTES); }
From source file:com.bdb.weather.display.day.DayHumidityPane.java
@Override protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) { plot.clearAnnotations();// www. ja v a2 s . c om if (summaryRecord == null) return; LocalDateTime highTime = summaryRecord.getMaxOutdoorHumidityTime(); Humidity highHumidity = summaryRecord.getMaxOutdoorHumidity(); LocalDateTime lowTime = summaryRecord.getMinOutdoorHumidityTime(); Humidity lowHumidity = summaryRecord.getMinOutdoorHumidity(); if (highTime == null || highHumidity == null || lowTime == null || lowHumidity == null) return; String highAnnotation = highHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " " + DisplayConstants.formatTime(highTime.toLocalTime()); String lowAnnotation = lowHumidity.toString() + Humidity.Unit.RELATIVE_HUMIDITY + " " + DisplayConstants.formatTime(lowTime.toLocalTime()); XYTextAnnotation a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime), highHumidity.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.addAnnotation(a); a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), lowHumidity.get()); a.setTextAnchor(TextAnchor.TOP_CENTER); plot.addAnnotation(a); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
private List<TicketCategoryModification> getPreSalesTicketCategoryModifications(boolean firstBounded, int firstSeats, boolean lastBounded, int lastSeats) { LocalDateTime start = LocalDateTime.now().plusMinutes(4); return Arrays.asList( new TicketCategoryModification(null, "defaultFirst", firstSeats, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", firstBounded, null, null, null, null, null), new TicketCategoryModification(null, "defaultLast", lastSeats, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", lastBounded, null, null, null, null, null)); }
From source file:com.bdb.weather.display.day.DayTemperaturePane.java
@Override public void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) { plot.clearAnnotations();/*from w w w . java 2s. c om*/ summary = summaryRecord; if (summaryRecord == null) return; LocalDateTime highTime = summaryRecord.getMaxOutdoorTempTime(); Temperature outdoorHighTemp = summaryRecord.getMaxOutdoorTemp(); LocalDateTime lowTime = summaryRecord.getMinOutdoorTempTime(); Temperature outdoorLowTemp = summaryRecord.getMinOutdoorTemp(); if (highTime == null || outdoorHighTemp == null || lowTime == null || outdoorLowTemp == null) return; String highAnnotation = outdoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " " + DisplayConstants.formatTime(highTime.toLocalTime()); String lowAnnotation = outdoorLowTemp.toString() + " " + Temperature.getDefaultUnit() + " " + DisplayConstants.formatTime(lowTime.toLocalTime()); XYTextAnnotation a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(highTime), outdoorHighTemp.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.addAnnotation(a); a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), outdoorLowTemp.get()); a.setTextAnchor(TextAnchor.TOP_CENTER); plot.addAnnotation(a); highTime = summaryRecord.getMaxIndoorTempTime(); Temperature indoorHighTemp = summaryRecord.getMaxIndoorTemp(); lowTime = summaryRecord.getMinIndoorTempTime(); Temperature indoorLowTemp = summaryRecord.getMinIndoorTemp(); highAnnotation = indoorHighTemp.toString() + " " + Temperature.getDefaultUnit() + " " + DisplayConstants.formatTime(highTime.toLocalTime()); lowAnnotation = indoorLowTemp + " " + Temperature.getDefaultUnit() + " " + DisplayConstants.formatTime(lowTime.toLocalTime()); a = new XYTextAnnotation(highAnnotation, TimeUtils.localDateTimeToEpochMillis(highTime), indoorHighTemp.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.addAnnotation(a); a = new XYTextAnnotation(lowAnnotation, TimeUtils.localDateTimeToEpochMillis(lowTime), indoorLowTemp.get()); a.setTextAnchor(TextAnchor.TOP_CENTER); plot.addAnnotation(a); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testNoPublicCategoryAvailable() { LocalDateTime start = LocalDateTime.now().minusHours(1); LocalDateTime end = LocalDateTime.now().plusHours(1); List<TicketCategoryModification> categories = Arrays.asList( new TicketCategoryModification(null, "default", 2, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default2", 10, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Pair<Event, String> eventAndUsername = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository); Event event = eventAndUsername.getKey(); List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); TicketCategory first = ticketCategories.stream().filter(tc -> !tc.isAccessRestricted()).findFirst() .orElseThrow(IllegalStateException::new); reserveTickets(event, first, 2);//from ww w . ja v a 2 s . c o m assertTrue( waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH)); assertTrue(waitingQueueManager.subscribe(event, new CustomerName("John Doe 2", "John", "Doe 2", event), "john@doe2.com", null, Locale.ENGLISH)); ZoneId zoneId = event.getZoneId(); Result<TicketCategory> ticketCategoryResult = eventManager.updateCategory(first.getId(), event, new TicketCategoryModification(first.getId(), first.getName(), 3, fromZonedDateTime(first.getInception(zoneId)), fromZonedDateTime(first.getExpiration(zoneId)), Collections.emptyMap(), first.getPrice(), false, "", true, null, null, null, null, null), eventAndUsername.getValue()); assertTrue(ticketCategoryResult.isSuccess()); assertEquals(1, ticketRepository.countReleasedTicketInCategory(event.getId(), first.getId()).intValue()); //now we should have an extra available ticket List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(1, subscriptions.size()); }