List of usage examples for org.joda.time LocalTime LocalTime
public LocalTime()
From source file:com.axelor.tool.template.TemplateMaker.java
License:Open Source License
public String make() { if (Strings.isNullOrEmpty(this.template)) { throw new IllegalArgumentException(I18n.get(IExceptionMessage.TEMPLATE_MAKER_2)); }//from ww w . j av a 2 s.c o m ST st = new ST(stGroup, template); Map<String, Object> _map = Maps.newHashMap(); if (localContext != null && !localContext.isEmpty()) { _map.putAll(localContext); } _map.putAll(context); //Internal context _map.put("__user__", AuthUtils.getUser()); _map.put("__date__", new LocalDate()); _map.put("__time__", new LocalTime()); _map.put("__datetime__", new LocalDateTime()); for (String key : _map.keySet()) { st.add(key, _map.get(key)); } return _make(st); }
From source file:com.bank.service.internal.DefaultTransferService.java
License:Apache License
@Override @Transactional/*w w w.j a va 2s.co m*/ public TransferReceipt transfer(double amount, String srcAcctId, String dstAcctId) throws InsufficientFundsException { if (amount < minimumTransferAmount) { throw new IllegalArgumentException( format("transfer amount must be at least $%.2f", minimumTransferAmount)); } if (timeService != null && !timeService.isServiceAvailable(new LocalTime())) { throw new OutOfServiceException(); } TransferReceipt receipt = new TransferReceipt(); Account srcAcct = accountRepository.findById(srcAcctId); Account dstAcct = accountRepository.findById(dstAcctId); receipt.setInitialSourceAccount(srcAcct); receipt.setInitialDestinationAccount(dstAcct); double fee = feePolicy.calculateFee(amount); if (fee > 0) { try { srcAcct.debit(fee); } catch (InsufficientFundsException e) { // TODO Auto-generated catch block e.printStackTrace(); } } receipt.setTransferAmount(amount); receipt.setFeeAmount(fee); try { srcAcct.debit(amount); } catch (InsufficientFundsException e) { throw new InsufficientFundsException(srcAcct, amount); } dstAcct.credit(amount); accountRepository.updateBalance(srcAcct); accountRepository.updateBalance(dstAcct); receipt.setFinalSourceAccount(srcAcct); receipt.setFinalDestinationAccount(dstAcct); return receipt; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.LoginPageImpl.java
License:Open Source License
/** * Click the submit button.//from w w w.j a v a 2 s. c om * @param userName the user name. * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickSubmit(java.lang.String) */ @Override public void clickSubmit(String userName) { LogUtil.setLogString("Click Login Button", true, CustomLogLevel.LOW); final WebElement loginBtn = getElement(getDriver(), By.className(LOGIN_SUBMIT), TINY_TIMEOUT); getAction().click(loginBtn); WaitUtil.tinyWait(); // getAction().rejectAlert(); String currentUTCTime = DateUtil.getUTCCurrentTimeStamp(); LogUtil.setLogString("\033[46;1mLOGIN REQUEST - UTC TIME: " + currentUTCTime + "\033[0m", true, CustomLogLevel.LOW); setLoginStartTime(new LocalTime()); setLoggedIn(isLoadingIconNotDisplayed()); setLoggedInUser(userName); currentUTCTime = DateUtil.getUTCCurrentTimeStamp(); LogUtil.setLogString(LogSection.END, "Login " + (isLoggedIn() ? "Succeeded" : "Failed"), true); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java
License:Open Source License
/** * Checks if is page loaded.//from ww w .j a va 2s . c o m * @return true, if is page loaded * @see com.ecofactor.qa.automation.mobile.page.BasePage#isPageLoaded() */ @Override public boolean isPageLoaded() { getAction().rejectAlert(); getAction().clickTryAgain(); setLogString("Verify Thermostat Page Loaded.", true, CustomLogLevel.LOW); isDisplayed(getDriver(), By.className(UNUSED_BTM_CONTAINER), TINY_TIMEOUT); isDisplayed(getDriver(), By.className(UNUSED_TOP_CONTAINER), TINY_TIMEOUT); loginPage.setLoggedIn(true); setPageLoadTimeOnLogin(new LocalTime()); return isDisplayed(getDriver(), By.className(TH_AXIS_CONTAINER), TINY_TIMEOUT) && isDisplayed(getDriver(), By.className(LOCATION_NAME), TINY_TIMEOUT) && isDisplayed(getDriver(), By.className(MENU), TINY_TIMEOUT); }
From source file:com.guavabot.alarmpreference.Alarm.java
License:Apache License
/** * Default alarm is off, with time set to current time and all week days activated */ public Alarm() { this(false, new LocalTime(), 0x7F); }
From source file:com.guavabot.alarmpreference.Alarm.java
License:Apache License
private void setValues(JSONObject json) { mAlarmOn = json.optBoolean(KEY_ALARM_ON, true); String time = json.optString(KEY_TIME, null); mTime = time != null ? TIME_FMT.parseLocalTime(time) : new LocalTime(); mWeeklyAlarms = json.optInt(KEY_WEEKLY_ALARMS, 0x7F); //default 7 days on mId = json.optInt(KEY_ID, -1);/*from w ww . j a v a 2 s. c o m*/ }
From source file:com.sleepbot.datetimepicker.time.TimePicker.java
License:Open Source License
public TimePicker(final Context context, final AttributeSet attrs) { super(context, attrs); this.ctx = context; final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DatePicker, 0, 0); mTime = new LocalTime(); try {/* ww w . j ava2s .co m*/ mTime = mTime.withHourOfDay(a.getInt(R.styleable.TimePicker_initialHour, 0)); mTime = mTime.withMinuteOfHour(a.getInt(R.styleable.TimePicker_initialMinute, 0)); } finally { a.recycle(); } this.mIs24HourMode = DateTimeHelper.is24HourLocale(Helpers.getLocale(context)); this.layout = inflate(context, R.layout.time_picker_view, this); initLayout(); }
From source file:config.TimeManipulation.java
License:Open Source License
public String getServerTime(int Offset) { LocalTime Time = new LocalTime(); Time = Time.plusHours(Offset); DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern("HH:mm").toFormatter(); return Time.toString(outputFormat); }
From source file:de.appsolve.padelcampus.admin.controller.bookings.AdminBookingsReservationsController.java
@RequestMapping(method = POST, value = "booking/{bookingId}") public ModelAndView postEditBooking(@PathVariable("bookingId") Long bookingId, @Valid @ModelAttribute("Model") ReservationRequest model, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return getEditView(model); }//from www . j av a2 s.c o m try { LocalDate today = new LocalDate(); LocalTime now = new LocalTime(); if (model.getStartDate().compareTo(today) < 0 || (model.getStartDate().equals(today) && model.getStartTime().compareTo(now) < 0)) { throw new Exception(msg.get("RequestedTimeIsInThePast")); } /* only one offer possible */ Offer offer = model.getOffers().iterator().next(); /* make sure to not modify booking before we know it can be changed b/c auf auto transaction commit */ Booking booking = bookingDAO.findById(bookingId); List<CalendarConfig> calendarConfigs = calendarConfigDAO.findFor(model.getStartDate()); //throws CalendarConfigException Iterator<CalendarConfig> iterator = calendarConfigs.iterator(); while (iterator.hasNext()) { CalendarConfig calendarConfig = iterator.next(); if (!bookingUtil.isHoliday(model.getStartDate(), calendarConfig)) { List<Booking> confirmedBookings = bookingDAO.findBlockedBookingsForDate(model.getStartDate()); //remove the current booking as we want to update it confirmedBookings.remove(booking); OfferDurationPrice offerDurationPrice = bookingUtil.getOfferDurationPrice(calendarConfigs, confirmedBookings, model.getStartDate(), model.getStartTime(), offer); if (offerDurationPrice != null) { TimeSlot timeSlot = new TimeSlot(); timeSlot.setDate(model.getStartDate()); timeSlot.setStartTime(model.getStartTime()); timeSlot.setEndTime(model.getEndTime()); timeSlot.setConfig(calendarConfig); Long bookingSlotsLeft = bookingUtil.getBookingSlotsLeft(timeSlot, offer, confirmedBookings); if (bookingSlotsLeft >= 1) { BigDecimal price = offerDurationPrice.getDurationPriceMap() .get(booking.getDuration().intValue()); booking.setAmount(price); booking.setBlockingTime(new LocalDateTime()); booking.setBookingDate(model.getStartDate()); booking.setBookingTime(model.getStartTime()); booking.setComment(model.getComment()); booking.setDuration(getDuration(model, calendarConfig)); booking.setOffer(offer); booking.setOfferOptions(model.getOfferOptions()); booking.setPaymentConfirmed(model.getPaymentConfirmed()); booking.setPaymentMethod(PaymentMethod.Reservation); booking.setPublicBooking(model.getPublicBooking()); bookingDAO.saveOrUpdate(booking); return redirectToIndex(); } } } } throw new Exception(msg.get("NoCourtReservationsForSelectedDateTime")); } catch (Exception e) { LOG.error(e); bindingResult.addError(new ObjectError("id", e.getMessage())); return getEditView(model); } }
From source file:de.appsolve.padelcampus.controller.bookings.BookingsController.java
@RequestMapping(value = "booking/{UUID}/cancel", method = POST) public ModelAndView cancelBooking(@PathVariable("UUID") String UUID, HttpServletRequest request) { Booking booking = bookingDAO.findByUUID(UUID); if (booking == null) { throw new ResourceNotFoundException(); }/*from w w w . j a v a 2s .c o m*/ Player user = sessionUtil.getUser(request); if (user == null) { return new ModelAndView("/login?redirect=" + request.getRequestURI()); } if (!booking.getPlayer().equals(user)) { return new ModelAndView("error/403"); } try { validateBookingCancellation(booking); //send replacement voucher only for valid payments if (booking.getPaymentMethod() != null && !booking.getPaymentMethod().equals(PaymentMethod.Reservation) && booking.getConfirmed() && booking.getPaymentConfirmed()) { Long maxDuration; LocalDate validUntilDate; LocalTime validFromTime; LocalTime validUntilTime; Set<Offer> offers; Set<CalendarWeekDay> weekDays; Voucher oldVoucher = booking.getVoucher(); if (oldVoucher != null) { maxDuration = oldVoucher.getDuration(); offers = oldVoucher.getOffers(); validUntilDate = oldVoucher.getValidUntil(); validFromTime = oldVoucher.getValidFromTime(); validUntilTime = oldVoucher.getValidUntilTime(); weekDays = oldVoucher.getCalendarWeekDays(); } else { maxDuration = booking.getDuration(); offers = new HashSet<>(Arrays.asList(booking.getOffer())); validUntilDate = booking.getBookingDate().plusYears(1); validFromTime = new LocalTime().withHourOfDay(Constants.BOOKING_DEFAULT_VALID_FROM_HOUR) .withMinuteOfHour(Constants.BOOKING_DEFAULT_VALID_FROM_MINUTE); validUntilTime = new LocalTime().withHourOfDay(Constants.BOOKING_DEFAULT_VALID_UNTIL_HOUR) .withMinuteOfHour(Constants.BOOKING_DEFAULT_VALID_UNTIL_MINUTE); weekDays = new HashSet<>(Arrays.asList(CalendarWeekDay.values())); } String comment = "Replacement voucher for Booking [" + booking.toString() + "]"; Voucher voucher = VoucherUtil.createNewVoucher(comment, maxDuration, validUntilDate, validFromTime, validUntilTime, weekDays, offers); voucherDAO.saveOrUpdate(voucher); Mail mail = new Mail(); mail.setSubject(msg.get("VoucherMailSubject")); mail.setBody(msg.get("VoucherMailBody", new Object[] { booking.getPlayer().toString(), RequestUtil.getBaseURL(request), voucher.getDuration(), FormatUtils.DATE_MEDIUM.print(voucher.getValidUntil()), voucher.getUUID(), RequestUtil.getBaseURL(request) })); mail.addRecipient(booking.getPlayer()); mailUtils.send(mail, request); booking.setCancelled(true); booking.setCancelReason("cancellation with replacement voucher"); bookingDAO.saveOrUpdate(booking); } else { booking.setCancelled(true); booking.setCancelReason("cancellation by user"); bookingDAO.saveOrUpdate(booking); } bookingUtil.sendBookingCancellationNotification(request, booking); bookingMonitorUtil.notifyUsers(request, booking); } catch (Exception e) { LOG.error("Error during booking cancellation", e); ModelAndView cancellationView = getCancellationView(booking); cancellationView.addObject("error", e.getMessage()); return cancellationView; } return getCancellationSuccessView(booking); }