List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:edu.uoc.json.controller.MeetingController.java
@RequestMapping(method = RequestMethod.PUT) public @ResponseBody JSONResponse startRecord(HttpSession session) { JSONResponse response = new JSONResponse(); try {//from w ww . j a va 2 s . c o m Room room = (Room) session.getAttribute(Constants.ROOM_SESSION); MeetingRoom meeting = (MeetingRoom) session.getAttribute(Constants.MEETING_SESSION); User user = (User) session.getAttribute(Constants.USER_SESSION); if (user != null && meeting != null) { meeting = meetingDao.findById(meeting.getId()); room = this.roomDao.findByRoomCode(room.getId()); room.setIs_blocked(true); room.setReason_blocked(Constants.REASON_BLOCK_RECORDING); this.roomDao.save(room); meeting.setRecorded((byte) 1); //meeting.setPath(meeting.getPath().replaceAll("_", "/")); meeting.setStart_record(new Timestamp(new Date().getTime())); this.meetingDao.save(meeting); response.setOk(true); } } catch (Exception e) { logger.error("Error starting record ", e); } return response; }
From source file:com.nettyhttpserver.server.util.HttpRequestHandler.java
public static void handle(ChannelHandlerContext ctx, HttpRequest req, DefaultChannelGroup channels) { allChannels = channels;// ww w . j a va 2 s. c om FullHttpResponse response = null; boolean keepAlive = isKeepAlive(req); String requestUri = req.getUri().toLowerCase(); /* * Write data about request to database */ ServerRequestDTO requestServiceDTO = new ServerRequestDTO(); requestServiceDTO.setIP(((InetSocketAddress) ctx.channel().remoteAddress()).getHostString()); requestServiceDTO.setLastTimestamp(new Timestamp(System.currentTimeMillis()).toString()); serverRequestService.setServerRequest(requestServiceDTO); if (is100ContinueExpected(req)) { ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE)); } /* * If request /hello */ if (Requests.HELLO.toString().equalsIgnoreCase(requestUri)) { content = Unpooled .unreleasableBuffer(Unpooled.copiedBuffer("<h1>Hello World!</h1>", CharsetUtil.UTF_8)); response = new DefaultFullHttpResponse(HTTP_1_1, OK, content.duplicate()); /* * Create timer for /hello page. */ timer.newTimeout(new ResponseTimerTask(ctx, response, keepAlive), 10, TimeUnit.SECONDS); writeToResponse(ctx, response, keepAlive); return; } /* * if request uri is /status */ if (Requests.STATUS.toString().equalsIgnoreCase(requestUri)) { content = Unpooled.unreleasableBuffer(Unpooled.copiedBuffer(generateStatus(), CharsetUtil.UTF_8)); response = new DefaultFullHttpResponse(HTTP_1_1, OK, content.duplicate()); writeToResponse(ctx, response, keepAlive); return; } /* * If redirect */ if (requestUri.matches(Requests.REDIRECT.toString())) { QueryStringDecoder qsd = new QueryStringDecoder(requestUri); List<String> redirectUrl = qsd.parameters().get("url"); response = new DefaultFullHttpResponse(HTTP_1_1, FOUND); response.headers().set(LOCATION, redirectUrl); /* * Redirect database routine * Write url to database */ RedirectRequestDTO requestRedirectDTO = new RedirectRequestDTO(); requestRedirectDTO.setUrl(redirectUrl.get(0)); redirectRequestService.setRedirectRequest(requestRedirectDTO); } else { /* * If request URI is not handled by server. */ response = new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN); } writeToResponse(ctx, response, keepAlive); }
From source file:com.iisigroup.cap.rule.service.impl.FactorMntServiceImpl.java
@Override public void insertTestCaseInfoData() { BigDecimal[] amount = new BigDecimal[] { new BigDecimal(100000), new BigDecimal(150000), new BigDecimal(900000), new BigDecimal(999999), new BigDecimal(50000), new BigDecimal(330000), new BigDecimal(550000), new BigDecimal(330000), new BigDecimal(150000), new BigDecimal(260000), new BigDecimal(440000), new BigDecimal(100000), new BigDecimal(880000), new BigDecimal(330000), new BigDecimal(150000), new BigDecimal(150000), new BigDecimal(250000), new BigDecimal(440000), new BigDecimal(130000), new BigDecimal(300000) }; Integer[] overDueDay = new Integer[] { 20, 90, 20, 31, 20, 20, 44, 29, 20, 77, 30, 66, 88, 20, 66, 90, 11, 30, 20, 15 };//from w w w . jav a2 s . c om List<CaseInfo> caseList = new ArrayList<CaseInfo>(); Calendar cal = Calendar.getInstance(); int count = 1; for (int j = 1; j <= 20; j++) { for (int i = count; i <= (5000 * j); i++) { CaseInfo cas = new CaseInfo(); cas.setCasNo(StringUtils.leftPad(String.valueOf(i), 20, '0')); int result = (int) (Math.random() * (20 - 1) + 1); cas.setAmount(amount[result]); result = (int) (Math.random() * (20 - 1) + 1); cas.setOverDueDay(overDueDay[result]); cas.setCreator("System"); cas.setCreateTime(new Timestamp(cal.getTimeInMillis())); caseList.add(cas); count++; } caseInfoDao.save(caseList); System.out.println(" case info records :: " + caseList.size()); } }
From source file:com.redhat.rhn.frontend.action.systems.monitoring.ProbeGraphAction.java
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest req, HttpServletResponse resp) throws Exception { RequestContext rctx = new RequestContext(req); Probe probe = rctx.lookupProbe();//from w w w . j av a 2 s . co m String[] metrics = req.getParameterValues(METRICS); Long start = rctx.getParamAsLong(STARTTS); Long end = rctx.getParamAsLong(ENDTS); if (start == null || end == null) { log.debug("No start or end date passed into execute()"); return null; } Timestamp startts = new Timestamp(start.longValue()); Timestamp endts = new Timestamp(end.longValue()); List tsdList = MonitoringManager.getInstance().getProbeDataList(probe, metrics, startts, endts); if (rctx.isRequestedExport()) { writeExport(tsdList, resp, metrics, rctx.getCurrentUser().getCsvSeparator()); } else { writeGraph(tsdList, resp, req, metrics, startts, endts); } return null; }
From source file:com.yunmel.syncretic.core.BaseController.java
@InitBinder public void initBinder(WebDataBinder binder) { // String??StringHTML?XSS binder.registerCustomEditor(String.class, new PropertyEditorSupport() { @Override/* w w w. j a va2 s . c o m*/ public void setAsText(String text) { setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim())); } @Override public String getAsText() { Object value = getValue(); return value != null ? value.toString() : ""; } }); // Date ? binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { try { setValue(DateUtils.parseDate(text, "yyyy-MM-dd HH:mm:ss")); } catch (ParseException e) { e.printStackTrace(); } } }); // Timestamp ? binder.registerCustomEditor(Timestamp.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { Date date = null; try { date = DateUtils.parseDate(text, "yyyy-MM-dd HH:mm:ss"); } catch (ParseException e) { e.printStackTrace(); } setValue(date == null ? null : new Timestamp(date.getTime())); } }); }
From source file:com.questdb.net.http.handlers.QueryHandlerSmallBufferTest.java
@Test(expected = MalformedChunkCodingException.class) public void testColumnValueTooLargeForBuffer() throws Exception { StringBuilder allChars = new StringBuilder(); for (char c = Character.MIN_VALUE; c < 0xD800; c++) { // allChars.append(c);/*from w w w. ja va2s .c o m*/ } String allCharString = allChars.toString(); QueryHandlerTest.generateJournal("xyz", allCharString, 1.900232E-10, 2.598E20, Long.MAX_VALUE, Integer.MIN_VALUE, new Timestamp(-102023)); String query = "select x, id from xyz \n limit 1"; QueryHandlerTest.download(query, temp); }
From source file:de.kaiserpfalzEdv.infopir.backend.db.BaseEntity.java
public void setLastModifiedDate(final DateTime timestamp) { lastModified = new Timestamp(timestamp.getMillis()); }
From source file:com.saggezza.jtracker.track.PayloadMapC.java
/** * {@inheritDoc}//from w w w .j av a 2 s .c o m * @return */ public PayloadMap setTimestamp() { String tstamp = new Timestamp(System.currentTimeMillis()).toString(); this.parameters.put("dtm", tstamp); // this.parameters.put("dtm", String.valueOf(System.currentTimeMillis())); return new PayloadMapC(this.parameters, this.configurations); }
From source file:com.example.controller.user.OrderController.java
@RequestMapping(value = "/restaurants/{rest_id}/lunch/{name}/order", method = RequestMethod.POST) public String order(@PathVariable Long rest_id, @PathVariable String name) { if (DataHelper.isCanCreateOrder()) { Restaurant restaurant = restaurantRepository.findOne(rest_id); if (restaurant != null) { Order order = orderRepository.findByCustomerLoginAndUpdatedBetween( SecurityContextHolder.getContext().getAuthentication().getName(), DataHelper.getYesterdayOrderTime(), DataHelper.getTodayOrderTime()); if (order == null) { order = new Order(); }/*from w w w . j a v a2s . c o m*/ order.setUpdated(new Timestamp(Calendar.getInstance().getTimeInMillis())); order.setCustomer(userRepository .findByLogin(SecurityContextHolder.getContext().getAuthentication().getName())); order.setLunchMenu(lunchMenuRepository.findByRestaurantAndNameAndUpdatedBetween(restaurant, name, DataHelper.getYesterdayOrderTime(), DataHelper.getTodayOrderTime())); orderRepository.save(order); return "ok"; } else throw new IllegalArgumentException("Restaurant not found"); } else return "Can't create order, you can create order tommorow before 11:00 by" + ZoneId.systemDefault().getId(); }
From source file:edu.uoc.json.controller.UserMeetingController.java
@RequestMapping(method = RequestMethod.POST) public @ResponseBody JSONResponse addUser(@RequestBody JSONRequest username, HttpSession session) { JSONResponse response = new JSONResponse(); try {/* w w w . j ava 2 s . c o m*/ Room room = (Room) session.getAttribute(Constants.ROOM_SESSION); MeetingRoom meeting = (MeetingRoom) session.getAttribute(Constants.MEETING_SESSION); User user = (User) session.getAttribute(Constants.USER_SESSION); User userToAdd = userDao.findByUserName(username.getRequest()); if (user != null && meeting != null) { meeting = meetingDao.findById(meeting.getId()); if (meeting.getRecorded() != (byte) 1) { UserMeetingId mId = new UserMeetingId(); mId.setMeeting(meeting); mId.setUser(userToAdd); UserMeeting userMeetingCheck = userMeetingDao.findUserMeetingByPK(mId); if (userMeetingCheck.getPk() == null || userMeetingCheck.getPk().getUser() == null) { Course course = (Course) session.getAttribute(Constants.COURSE_SESSION); String meetingIdPath = course.getCoursekey() + "_" + room.getKey() + "_" + meeting.getId(); Date date = new Date(); UserMeeting userMeeting = new UserMeeting(mId, new Timestamp(date.getTime()), meetingIdPath + "_" + user.getUsername()); userMeetingDao.save(userMeeting); UserController uController = new UserController(); uController.updateHistoryUserMeetingTable(userMeeting); } meeting.setNumber_participants(userMeetingDao.countNumberParticipants(meeting)); if (meeting.getNumber_participants() > 0 && meeting.getFinished() == (byte) 1) { meeting.setFinished((byte) 0); meeting.setEnd_meeting(null); } meetingDao.save(meeting); } response.setOk(true); } } catch (Exception e) { logger.error("Adding user ", e); } return response; }