List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:todolist.ui.controllers.SettingsController.java
/** * formatChartLabelsWithDate/*from ww w. j a va 2 s . co m*/ * * @param format */ private void formatChartLabelsWithDate(org.joda.time.format.DateTimeFormatter format) { monday = String.format(monday, LocalDateTime.now().withDayOfWeek(1).toString(format)); tuesday = String.format(tuesday, LocalDateTime.now().withDayOfWeek(2).toString(format)); wednesday = String.format(wednesday, LocalDateTime.now().withDayOfWeek(3).toString(format)); thursday = String.format(thursday, LocalDateTime.now().withDayOfWeek(4).toString(format)); friday = String.format(friday, LocalDateTime.now().withDayOfWeek(5).toString(format)); saturday = String.format(saturday, LocalDateTime.now().withDayOfWeek(6).toString(format)); sunday = String.format(sunday, LocalDateTime.now().withDayOfWeek(7).toString(format)); }
From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java
public String coinsUpdate() { String message = null;/*from w ww. j ava 2 s . c om*/ Map session = ActionContext.getContext().getSession(); UserEntity user = (UserEntity) session.get("user"); if (coins == null) { //log.debug(""+user); // DepositCardEntity card = cardService.findByCardAccount(cardAccount, cardPassword); if (card != null) { try { if (card.isState()) { user.setCoins(user.getCoins() + card.getPoint()); //log.debug("coins"+card.getPoint()); message = card.getPoint().toString(); card.setUserId(user); card.setState(false); service.noPswdUpdate(user); log.debug("?"); card.setUseTime(LocalDateTime.now()); cardService.update(card); } else { log.debug("?"); // this.addFieldError("cardError", // this.getText("alreadyuse.card")); message = "error ?"; } } catch (Exception e) { log.debug("coins"); // this.addFieldError("cardError", // this.getText("fieldvalue.card")); message = "error coins"; e.printStackTrace(); } } else { log.debug("?"); this.addFieldError("cardError", this.getText("fieldvalue.card")); message = "error ?"; } log.debug("coins?"); } else { try { user.setCoins(user.getCoins() + coins); message = new Gson().toJson(service.update(user)); } catch (Exception e) { e.printStackTrace(); } } inputStream = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); return "message"; }
From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java
public String insert() throws Exception { log.debug(""); this.iValidate(1);// if (this.getFieldErrors().isEmpty()) { model.setCreator("Guest"); // model.setModifier("Guest"); // model.setCreateTime(LocalDateTime.now()); model.setModifiedTime(LocalDateTime.now()); model.setCoins(0l);/*from w ww. j a v a 2 s . com*/ model.setUserState(new String(service.getNewPassword())); String cardId = model.getUserCardId().toUpperCase(); model.setUserCardId(cardId); //model.setUserPassword(userPassword.getBytes()); log.debug("Model = {}", model); try { service.insert(service.encoding(model)); UserEntity entity = service.getByUserAccount(model.getUserAccount()); log.debug("" + entity); Map<String, UserEntity> session = (Map) ServletActionContext.getContext().getSession(); session.put("user", entity); log.debug("?"); } catch (Exception e) { log.debug("!!!!"); this.addFieldError("other", this.getText("invalid.fieldvalue.other")); e.printStackTrace(); return ERROR; } return SUCCESS; } else { log.debug("" + getFieldErrors().toString()); return ERROR; } }
From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java
public String update() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); Map session = ActionContext.getContext().getSession(); UserEntity userEntity = (UserEntity) session.get("user"); if (getFieldErrors().isEmpty()) { log.debug(""); log.debug("Model = {}", model); model.setModifier("Guest"); model.setModifiedTime(LocalDateTime.now()); //log.debug(""+userEntity); try {/*from ww w . j a v a 2 s .c o m*/ if (model != null) { log.debug(":" + userPassword); if (userPassword != null && userPassword.length() > 5) { model.setUserPassword(oldUserPassword.getBytes()); model = service.encoding(model); if (userEntity != null && Arrays.equals(userEntity.getUserPassword(), model.getUserPassword())) { log.debug("? ?"); model.setUserPassword(userPassword.getBytes()); } else { log.debug("??"); this.addFieldError("passwordError", this.getText("invalid.fieldvalue.password")); return ERROR; } } userEntity.setUserPassword(service.encoding(model).getUserPassword()); userEntity.setUserName(model.getUserName()); userEntity.setUserBirthday(model.getUserBirthday()); userEntity.setUserEmail(model.getUserEmail()); userEntity.setUserPhone(model.getUserPhone()); service.update(userEntity); log.debug("!!?!!"); request.setAttribute("updateSuccess", "?"); } } catch (Exception e) { log.debug("!!!!"); this.addFieldError("other", this.getText("invalid.fieldvalue.other")); request.setAttribute("updateFail", ""); e.printStackTrace(); } return SUCCESS; } return ERROR; }
From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java
public String updateUserInfo() { HttpServletRequest request = ServletActionContext.getRequest(); Map session = ActionContext.getContext().getSession(); UserEntity userEntity = (UserEntity) session.get("user"); log.debug(""); log.debug("Model = {}", model); model.setModifier("Guest"); model.setModifiedTime(LocalDateTime.now()); // log.debug(""+userEntity); try {/*from w ww.j a v a2 s . c o m*/ if (model != null) { model = service.encoding(model); userEntity.setUserPassword(model.getUserPassword()); userEntity.setUserName(model.getUserName()); userEntity.setUserBirthday(model.getUserBirthday()); userEntity.setUserEmail(model.getUserEmail()); userEntity.setUserPhone(model.getUserPhone()); service.update(userEntity); log.debug("!!?!!"); inputStream = new ByteArrayInputStream("true".getBytes(StandardCharsets.UTF_8)); } } catch (Exception e) { log.debug("!!!!"); inputStream = new ByteArrayInputStream("false".getBytes(StandardCharsets.UTF_8)); e.printStackTrace(); } return "updateUserInfo"; }
From source file:tw.com.softleader.sportslottery.setting.web.UserAction.java
public String updateUserPassword() throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); Map session = ActionContext.getContext().getSession(); UserEntity userEntity = (UserEntity) session.get("user"); //log.debug("updateUserPassword()"); model.setModifier("Guest"); model.setModifiedTime(LocalDateTime.now()); if (getFieldErrors().isEmpty()) { log.debug(""); log.debug("Model = {}", model); // log.debug(""+userEntity); try {// w ww . jav a2 s .c om if (userPassword != null && userPassword.length() > 5) { model.setUserPassword(oldUserPassword.getBytes()); model = service.encoding(model); if (userEntity != null && Arrays.equals(userEntity.getUserPassword(), model.getUserPassword())) { model.setUserPassword(userPassword.getBytes()); userEntity.setUserPassword(service.encoding(model).getUserPassword()); service.update(userEntity); service.updateUserPasswordMail(userEntity); inputStream = new ByteArrayInputStream("true".getBytes(StandardCharsets.UTF_8)); } else { log.debug("??"); inputStream = new ByteArrayInputStream("false".getBytes(StandardCharsets.UTF_8)); } } } catch (Exception e) { log.debug("!!!!"); inputStream = new ByteArrayInputStream("false".getBytes(StandardCharsets.UTF_8)); e.printStackTrace(); } } return "updateUserPassword"; }
From source file:view.popups.AssignRoomsPopup.java
@Override public void display(String title) { cBDateTimeStart = new ComboBox(); cBDateTimeEnd = new ComboBox(); assignRooms = new PopupMenuButton("Tilfj inaktive rum i tidsperioden"); localDateTimeObject = LocalDateTime.now(); Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() { @Override/*from ww w. ja v a 2s . c om*/ public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) { return new ListCell<LocalDateTime>() { @Override public void updateItem(LocalDateTime item, boolean empty) { super.updateItem(item, empty); if (!empty) { String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1]; value = value.replaceFirst(value.substring(1, value.length()), value.substring(1, value.length()).toLowerCase()); setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/" + item.getMonthOfYear() + " - " + value); } } }; } }; cBDateTimeStart.setButtonCell(cellFactory.call(null)); cBDateTimeStart.setCellFactory(cellFactory); Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory2 = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() { @Override public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) { return new ListCell<LocalDateTime>() { @Override public void updateItem(LocalDateTime item, boolean empty) { super.updateItem(item, empty); if (!empty) { String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1]; value = value.replaceFirst(value.substring(1, value.length()), value.substring(1, value.length()).toLowerCase()); setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/" + item.getMonthOfYear() + " - " + value); } } }; } }; cBDateTimeEnd.setButtonCell(cellFactory2.call(null)); cBDateTimeEnd.setCellFactory(cellFactory2); setBottomHBoxPadding(15, 15, 15, 15); cBContainer = new VBox(20); cBContainer.setAlignment(Pos.CENTER); cBContainer.setPadding(new Insets(15, 15, 15, 15)); super.addToCenter(cBContainer); cBContainer.getChildren().addAll(cBDateTimeStart, cBDateTimeEnd); super.getBottomHBox().getChildren().add(0, assignRooms); assignRooms.setOnAction(e -> { }); }