List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:com.anyuan.thomweboss.controller.user.UserController.java
@RequestMapping(value = "add_user") public String add_user(HttpServletRequest req, HttpServletResponse resp) { Contact contact = new Contact(); contact.setEmail(req.getParameter("email")); Address address = new Address(); address.setCity(req.getParameter("city")); contact.setAddress(address);/* w ww . j a v a 2 s . c o m*/ Phone phone = new Phone(); phone.setNumber(req.getParameter("number")); contact.setPhone(phone); User user = new User(); user.setNickname(req.getParameter("nickname")); user.setUsername(req.getParameter("username")); user.setPassword(req.getParameter("password")); user.setCreatetime(new Timestamp(System.currentTimeMillis())); user.setGender(req.getParameter("gender")); user.setContact(contact); userService.save(user); req.setAttribute("listuser", userService.listAll()); return "users/list_user"; }
From source file:com.bitranger.parknshop.buyer.controller.AddCartController.java
@RequestMapping(value = "/addcart") public String addCart(HttpServletRequest req, Integer itemId) { PsItem psItem = psItemDao.findById(itemId); if (psItem == null) return Utility.error("Unexisted item"); PsCustomer currentCustomer = (PsCustomer) req.getSession().getAttribute("currentCustomer"); if (currentCustomer == null) return Utility.error("Not Login"); CartCustomerItem item = psCartCustomerItemDao .findById(new CartCustomerItemId(currentCustomer.getId(), itemId)); if (item != null) { item.setQuantity(item.getQuantity() + 1); psCartCustomerItemDao.update(item); return "redirect:/"; }/*w w w .j a va 2 s .c o m*/ CartCustomerItem transientItem = new CartCustomerItem(); transientItem.setId(new CartCustomerItemId(currentCustomer.getId(), itemId)); transientItem.setPsCustomer(currentCustomer); transientItem.setPsItem(psItem); transientItem.setQuantity(1); transientItem.setTimeCreated(new Timestamp(System.currentTimeMillis())); psCartCustomerItemDao.save(transientItem); org.springframework.orm.hibernate3.support.OpenSessionInViewFilter ss = new org.springframework.orm.hibernate3.support.OpenSessionInViewFilter(); return "redirect:/"; }
From source file:com.bitranger.parknshop.buyer.controller.CustomerRegister.java
/** * @param req//from w ww. j av a 2s .c o m * @param username * @param email * @param password * @param buyer * Set not null if the person to register is buyer * @param seller * Set not null if the person to register is seller * @return */ @RequestMapping(value = "/register") //, method=RequestMethod.POST) public String registerCustomer(HttpServletRequest req, String username, String email, String password, String role) { if (email == null || password == null || role == null) return Utility.error("Param Error."); if (role.equals("seller")) { log.debug("Seller Try to sign up."); Timestamp now = new Timestamp(System.currentTimeMillis()); PsSeller toAdd = new PsSeller(email, password, new Timestamp(System.currentTimeMillis())); toAdd.setNickname(username); toAdd.setTimeCreated(now); psSellerDao.save(toAdd); req.getSession().setAttribute("currentSeller", toAdd); } else if (role.equals("buyer")) { log.debug("Buyer Try to sign up."); Timestamp now = new Timestamp(System.currentTimeMillis()); PsCustomer toAdd = new PsCustomer(username, email, password, new Short((short) 0), now); psCustomerDao.save(toAdd); req.getSession().setAttribute("currentCustomer", toAdd); } else { log.debug("Parameter Error."); } return "redirect:/"; }
From source file:com.aionemu.gameserver.model.gameobjects.BrokerItem.java
/** * Used where registering item// w w w.ja v a2 s .c om * * @param item * @param price * @param seller * @param sellerId * @param sold * @param itemBrokerRace */ public BrokerItem(Item item, long price, String seller, int sellerId, BrokerRace itemBrokerRace, boolean partSale) { this.item = item; this.itemId = item.getItemTemplate().getTemplateId(); this.itemUniqueId = item.getObjectId(); this.itemCount = item.getItemCount(); this.itemCreator = item.getItemCreator(); this.price = price; this.seller = seller; this.sellerId = sellerId; this.itemBrokerRace = itemBrokerRace; this.isSold = false; this.isSettled = false; this.expireTime = new Timestamp(Calendar.getInstance().getTimeInMillis() + 691200000); // 8 days this.settleTime = new Timestamp(Calendar.getInstance().getTimeInMillis()); this.partSale = partSale; this.state = PersistentState.NEW; }
From source file:cs544.letmegiveexam.controller.QuestionSetController.java
@RequestMapping(value = "/questionSet/{Id}", method = RequestMethod.GET) public String startExam(Model model, HttpServletRequest request, HttpSession session, @PathVariable long Id) { QuestionSet questionSet = questionSetService.get(Id); //save exam for user java.util.Date date = new java.util.Date(); Timestamp currentTimestamp = new Timestamp(date.getTime()); //get user object from session User user = (User) session.getAttribute("user"); UserExam userExam = null;//from ww w. ja v a 2 s. c o m if (questionSet != null) { userExam = new UserExam(currentTimestamp, user, questionSet); userExamService.add(userExam); model.addAttribute("questionSetQuestions", userExam.getQuestionSet().getQuestionslist()); //session.setAttribute("questionSet", questionSet); model.addAttribute("questionSet", questionSet); model.addAttribute("subject", userExam.getQuestionSet().getQuestionslist().get(0).getSubject()); } model.addAttribute("userExam", userExam); return "userExam"; }
From source file:cz.zcu.kiv.eegdatabase.wui.components.table.TimestampConverter.java
@Override public Timestamp convertToObject(String value, Locale locale) { try {//from ww w . j ava2s . com long time = new SimpleDateFormat(getParsePattern()).parse(value).getTime(); return new Timestamp(time); } catch (ParseException e) { log.info(e.getMessage(), e); throw new ConversionException("Wrong Date Format: " + parsePattern); } }
From source file:iddb.runtime.db.model.dao.impl.mysql.UserDAOImpl.java
@Override public void save(User user) { String sql;/* ww w. ja v a 2 s. com*/ if (user.getKey() == null) { sql = "insert into user (loginid, roles, updated, created, password) values (?,?,?,?,?)"; } else { sql = "update user set loginid = ?," + "roles = ?," + "updated = ? where id = ? limit 1"; } Connection conn = null; try { conn = ConnectionFactory.getMasterConnection(); PreparedStatement st = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); st.setString(1, user.getLoginId()); st.setString(2, Functions.join(user.getRoles(), ",")); st.setTimestamp(3, new Timestamp(new Date().getTime())); if (user.getKey() != null) { st.setLong(4, user.getKey()); } else { st.setTimestamp(4, new Timestamp(new Date().getTime())); st.setString(5, user.getPassword()); } st.executeUpdate(); if (user.getKey() == null) { ResultSet rs = st.getGeneratedKeys(); if (rs != null && rs.next()) { user.setKey(rs.getLong(1)); } else { logger.warn("Couldn't get id for user {}", user.getLoginId()); } } } catch (SQLException e) { logger.error("Save: {}", e); } catch (IOException e) { logger.error("Save: {}", e); } finally { try { if (conn != null) conn.close(); } catch (Exception e) { } } }
From source file:fr.paris.lutece.plugins.extend.modules.comment.service.CommentService.java
/** * {@inheritDoc}//from w w w . ja v a 2 s . c o m */ @Override @Transactional(CommentPlugin.TRANSACTION_MANAGER) public void create(Comment comment) { Timestamp currentTimestamp = new Timestamp(new Date().getTime()); comment.setDateComment(currentTimestamp); comment.setDateLastModif(currentTimestamp); _commentDAO.insert(comment, CommentPlugin.getPlugin()); if (comment.getIdParentComment() > 0) { Comment parentComment = findByPrimaryKey(comment.getIdParentComment()); parentComment.setDateLastModif(currentTimestamp); update(parentComment); } CommentListenerService.createComment(comment.getExtendableResourceType(), comment.getIdExtendableResource(), comment.isPublished()); }
From source file:adalid.commons.util.TimeUtils.java
public static synchronized Timestamp currentTimestamp() { return new Timestamp(currentTimeMillis()); }
From source file:com.recomdata.grails.rositaui.utils.SignalService.java
public void sendSignal(Long jobId, Integer workflowStep, boolean success, String message) { try {//from ww w. jav a 2 s. c om ps.setLong(1, jobId); ps.setLong(2, workflowStep); ps.setTimestamp(3, new Timestamp(new java.util.Date().getTime())); ps.setBoolean(4, true); ps.setBoolean(5, success); ps.setString(6, message); ps.execute(); } catch (SQLException e) { e.printStackTrace(); } }