List of usage examples for org.joda.time LocalDateTime toLocalTime
public LocalTime toLocalTime()
From source file:cherry.sqlapp.controller.sqltool.search.SqltoolSearchControllerImpl.java
License:Apache License
@Override public SqltoolSearchForm getForm() { LocalDate today = bizDateTime.today(); SqltoolSearchForm form = new SqltoolSearchForm(); LocalDateTime from = LocalDateTimeUtil.rangeFrom(today.minusDays(defaultFromDays)); form.setRegisteredFromDt(from.toLocalDate()); form.setRegisteredFromTm(from.toLocalTime()); LocalDateTime to = LocalDateTimeUtil.rangeTo(today).minusSeconds(1); form.setRegisteredToDt(to.toLocalDate()); form.setRegisteredToTm(to.toLocalTime()); form.setSqlType(Arrays.asList(SqlType.CLAUSE, SqlType.STATEMENT, SqlType.LOAD)); form.setPublished(Arrays.asList(Published.PUBLIC, Published.PRIVATE)); return form;/*from w ww . j a v a 2s. c o m*/ }
From source file:cherry.sqlman.tool.search.SqlSearchControllerImpl.java
License:Apache License
private void initializeForm(SqlSearchForm form) { LocalDate today = bizDateTime.today(); LocalDateTime from = LocalDateTimeUtil.rangeFrom(today.minusDays(config.getSearchDefaultFromDays())); form.setRegisteredFromDt(from.toLocalDate()); form.setRegisteredFromTm(from.toLocalTime()); LocalDateTime to = LocalDateTimeUtil.rangeTo(today).minusSeconds(1); form.setRegisteredToDt(to.toLocalDate()); form.setRegisteredToTm(to.toLocalTime()); form.setSqlType(Arrays.asList(SqlType.CLAUSE, SqlType.STATEMENT, SqlType.LOAD)); form.setPublished(Arrays.asList(Published.PUBLIC, Published.PRIVATE)); }
From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemDateTime.java
License:Open Source License
public CosemDateTime(final LocalDateTime dateTime, final int deviation, final ClockStatus clockStatus) { this(dateTime.toLocalDate(), dateTime.toLocalTime(), deviation, clockStatus); }
From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemDateTime.java
License:Open Source License
public CosemDateTime(final LocalDateTime dateTime, final int deviation) { this(dateTime.toLocalDate(), dateTime.toLocalTime(), deviation); }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemDateTimeDto.java
License:Open Source License
public CosemDateTimeDto(final LocalDateTime dateTime, final int deviation, final ClockStatusDto clockStatus) { this(dateTime.toLocalDate(), dateTime.toLocalTime(), deviation, clockStatus); }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemDateTimeDto.java
License:Open Source License
public CosemDateTimeDto(final LocalDateTime dateTime, final int deviation) { this(dateTime.toLocalDate(), dateTime.toLocalTime(), deviation); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalTime createLocalTime(@Nonnull final LocalDateTime aLocalDateTime) { return aLocalDateTime.toLocalTime(); }
From source file:com.kccomy.orgar.ui.editor.NodeEditorFragment.java
License:Apache License
@Override protected void initViews(View view, Bundle savedInstanceState) { setHasOptionsMenu(true);/* w w w . ja v a 2 s. co m*/ FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab); fab.hide(); if (treeNode != null && action.equals(EditAction.EDIT)) { //?? headerEdt.setText(treeNode.getHeader()); bodyEdt.setText(treeNode.getBody()); LocalDateTime scheduled = treeNode.getTimestamp(OrgTimestamp.Type.SCHEDULED); if (scheduled != null) { scheduledDate = scheduled; scheduledTime = scheduled.toLocalTime(); scheduledDateBtn.setText(scheduledDate.toString(DATE_FORMAT)); scheduledTimeBtn.setText(scheduledTime.toString(TIME_FORMAT)); } LocalDateTime deadline = treeNode.getTimestamp(OrgTimestamp.Type.DEADLINE); if (deadline != null) { deadlineDate = deadline; deadlineTime = deadline.toLocalTime(); deadlineDateBtn.setText(deadlineDate.toString(DATE_FORMAT)); deadlineTimeBtn.setText(deadlineTime.toString(TIME_FORMAT)); } } ArrayAdapter<String> dataAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, Arrays.asList(todoArray)); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); todoSpinner.setAdapter(dataAdapter); todoSpinner.setOnItemSelectedListener(this); prioritySpinner.setOnItemSelectedListener(this); closedImg.setVisibility(View.GONE); closedDateBtn.setVisibility(View.GONE); closedTimeBtn.setVisibility(View.GONE); }
From source file:de.appsolve.padelcampus.utils.BookingUtil.java
private void addTimeSlot(List<TimeSlot> timeSlots, LocalDateTime time, CalendarConfig config, BigDecimal pricePerMinDuration) { TimeSlot timeSlot = new TimeSlot(); timeSlot.setDate(time.toLocalDate()); timeSlot.setStartTime(time.toLocalTime()); timeSlot.setEndTime(time.toLocalTime().plusMinutes(config.getMinDuration())); timeSlot.setConfig(config);/*from w w w . j a v a2 s. c o m*/ timeSlot.setPricePerMinDuration(pricePerMinDuration); //only add timeSlot if timeSlots does not already contain an entry that overlaps if (!overlaps(timeSlot, timeSlots)) { timeSlots.add(timeSlot); } }
From source file:de.appsolve.padelcampus.utils.BookingUtil.java
public OfferDurationPrice getOfferDurationPrice(List<CalendarConfig> configs, List<Booking> confirmedBookings, LocalDate selectedDate, LocalTime selectedTime, Offer selectedOffer) throws CalendarConfigException { List<TimeSlot> timeSlotsForDate = getTimeSlotsForDate(selectedDate, configs, confirmedBookings, Boolean.TRUE, Boolean.TRUE); boolean validStartTime = false; for (TimeSlot timeSlot : timeSlotsForDate) { if (timeSlot.getStartTime().equals(selectedTime)) { validStartTime = true;// w w w .ja v a2 s. co m break; } } OfferDurationPrice offerDurationPrices = null; if (validStartTime) { //convert to required data structure Map<Offer, List<CalendarConfig>> offerConfigMap = new HashMap<>(); for (CalendarConfig config : configs) { for (Offer offer : config.getOffers()) { if (offer.equals(selectedOffer)) { List<CalendarConfig> list = offerConfigMap.get(offer); if (list == null) { list = new ArrayList<>(); } list.add(config); //sort by start time Collections.sort(list); offerConfigMap.put(offer, list); } } } Iterator<Map.Entry<Offer, List<CalendarConfig>>> iterator = offerConfigMap.entrySet().iterator(); //for every offer while (iterator.hasNext()) { Map.Entry<Offer, List<CalendarConfig>> entry = iterator.next(); Offer offer = entry.getKey(); List<CalendarConfig> configsForOffer = entry.getValue(); //make sure the first configuration starts before the requested booking time if (selectedTime.compareTo(configsForOffer.get(0).getStartTime()) < 0) { continue; } LocalDateTime endTime = null; Integer duration = configsForOffer.get(0).getMinDuration(); BigDecimal pricePerMinute; BigDecimal price = null; CalendarConfig previousConfig = null; Map<Integer, BigDecimal> durationPriceMap = new TreeMap<>(); Boolean isContiguous = true; for (CalendarConfig config : configsForOffer) { //make sure there is no gap between calendar configurations if (endTime == null) { //first run endTime = getLocalDateTime(selectedDate, selectedTime).plusMinutes(config.getMinDuration()); } else { //break if there are durations available and calendar configs are not contiguous if (!durationPriceMap.isEmpty()) { //we substract min interval before the comparison as it has been added during the last iteration LocalDateTime configStartDateTime = getLocalDateTime(selectedDate, config.getStartTime()); if (!endTime.minusMinutes(config.getMinInterval()).equals(configStartDateTime)) { break; } } } Integer interval = config.getMinInterval(); pricePerMinute = getPricePerMinute(config); //as long as the endTime is before the end time configured in the calendar LocalDateTime configEndDateTime = getLocalDateTime(selectedDate, config.getEndTime()); while (endTime.compareTo(configEndDateTime) <= 0) { TimeSlot timeSlot = new TimeSlot(); timeSlot.setDate(selectedDate); timeSlot.setStartTime(selectedTime); timeSlot.setEndTime(endTime.toLocalTime()); timeSlot.setConfig(config); Long bookingSlotsLeft = getBookingSlotsLeft(timeSlot, offer, confirmedBookings); //we only allow contiguous bookings for any given offer if (bookingSlotsLeft < 1) { isContiguous = false; break; } if (price == null) { //see if previousConfig endTime - minInterval matches the selected time. if so, take half of the previous config price as a basis if (previousConfig != null && previousConfig.getEndTime() .minusMinutes(previousConfig.getMinInterval()).equals(selectedTime)) { BigDecimal previousConfigPricePerMinute = getPricePerMinute(previousConfig); price = previousConfigPricePerMinute.multiply( new BigDecimal(previousConfig.getMinInterval()), MathContext.DECIMAL128); price = price.add(pricePerMinute.multiply( new BigDecimal(duration - previousConfig.getMinInterval()), MathContext.DECIMAL128)); } else { price = pricePerMinute.multiply(new BigDecimal(duration.toString()), MathContext.DECIMAL128); } } else { //add price for additional interval price = price.add(pricePerMinute.multiply(new BigDecimal(interval.toString()), MathContext.DECIMAL128)); } price = price.setScale(2, RoundingMode.HALF_EVEN); durationPriceMap.put(duration, price); //increase the duration by the configured minimum interval and determine the new end time for the next iteration duration += interval; endTime = endTime.plusMinutes(interval); } if (!durationPriceMap.isEmpty()) { OfferDurationPrice odp = new OfferDurationPrice(); odp.setOffer(offer); odp.setDurationPriceMap(durationPriceMap); odp.setConfig(config); offerDurationPrices = odp; } if (!isContiguous) { //we only allow coniguous bookings for one offer. process next offer break; } previousConfig = config; } } } return offerDurationPrices; }