List of usage examples for java.util Date setYear
@Deprecated public void setYear(int year)
From source file:accountgen.controller.Controller.java
private void getListTags(Document doc, Person p) { Elements li = doc.select(".extra").select("li:not(.lab)"); p.setUsername(li.get(2).text());/*from w ww .j a v a 2 s. c om*/ p.setPassword(li.get(3).text()); p.setMmn(li.get(4).text()); p.setMastercard(li.get(6).text()); p.setSsn(""); Date d = new Date(); d.setDate(1); d.setYear(Integer.parseInt(li.get(7).text().split("/")[1]) - 1900); d.setMonth(Integer.parseInt(li.get(7).text().split("/")[0]) - 1); p.setExpires(d); p.setCvv2(li.get(8).text()); p.setFavoritecolor(li.get(9).text()); p.setOccupation(li.get(10).text()); p.setCompany(li.get(11).text()); p.setWebsite(li.get(12).text()); Vehicle v = new Vehicle(); v.setModel(li.get(13).text().split(" ")[li.get(13).text().split(" ").length - 1].trim()); v.setYear(Integer.parseInt(li.get(13).text().split(" ")[0].trim())); v.setBrand( li.get(13).text().replace(li.get(13).text().split(" ")[li.get(13).text().split(" ").length - 1], "") .replace(li.get(13).text().split(" ")[0], "").trim()); p.setVehicle(v); p.setUpsnr(li.get(14).text()); p.setBloodtype(li.get(15).text()); p.setWeight(li.get(16).text().split("\\(")[1].split(" ")[0]); p.setHeight(li.get(17).text().split("\\(")[1].split(" ")[0]); p.setGuid(li.get(18).text()); }
From source file:v2.ClientTest.java
@Test public void testDatesLaptop() throws APIException { Laptop laptop = new Laptop(); laptop.setStatus(Laptop.TAGGED_S0);/*from w w w . j a v a 2 s . co m*/ Date dateDelivered = new Date(); dateDelivered.setHours(12); dateDelivered.setMinutes(45); dateDelivered.setSeconds(10); dateDelivered.setMonth(3); dateDelivered.setYear(2012); laptop.setDateDelivered(dateDelivered); Date dateReceived = new Date(); dateReceived.setHours(1); dateReceived.setMinutes(41); dateReceived.setSeconds(10); dateReceived.setMonth(5); dateReceived.setYear(2012); laptop.setDateReceived(dateReceived); Date dateRecycled = new Date(); dateRecycled.setHours(1); dateRecycled.setMinutes(35); dateRecycled.setSeconds(10); dateRecycled.setMonth(4); dateRecycled.setYear(2012); laptop.setDateRecycled(dateRecycled); String nid = client.addLaptop(laptop); // Check date laptop // Laptop laptop = client.getLaptop(nid); // log.info(laptop); // log.info("Response test: "+nid); boolean result = client.deleteLaptop(nid); // log.info("It was deleted: "+result); Assert.assertTrue(result); }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.FormUpdateAction.java
public void doCommentInput(FlowSheetItem item, EctMeasurementTypesBean mtypeBean, MeasurementFlowSheet mFlowsheet, String inputType, String mInstructions, String comment, String date, String apptNo, HttpServletRequest request) { String temp = request.getParameter("template"); String demographicNo = request.getParameter("demographic_no"); HttpSession session = request.getSession(); String providerNo = (String) session.getAttribute("user"); String comments = comment;/*from w ww . j av a 2s .com*/ String dateObserved = date; java.util.Calendar calender = java.util.Calendar.getInstance(); String hour = Integer.toString(calender.get(java.util.Calendar.HOUR_OF_DAY)); String min = Integer.toString(calender.get(java.util.Calendar.MINUTE)); String second = Integer.toString(calender.get(java.util.Calendar.SECOND)); String dateEntered = dateObserved + " " + hour + ":" + min + ":" + second; comments = org.apache.commons.lang.StringEscapeUtils.escapeSql(comments); MsgStringQuote str = new MsgStringQuote(); ResultSet rs; String[] dateComp = date.split("-"); Date dateObs = new Date(); dateObs.setYear(Integer.parseInt(dateComp[0]) - 1900); dateObs.setMonth(Integer.parseInt(dateComp[1]) - 1); dateObs.setDate(Integer.parseInt(dateComp[2])); MeasurementDao measurementDao = (MeasurementDao) SpringUtils.getBean("measurementDao"); Measurement measurement = new Measurement(); measurement.setDemographicId(Integer.parseInt(demographicNo)); measurement.setDataField(""); measurement.setMeasuringInstruction(mInstructions); measurement.setComments(comments); measurement.setDateObserved(dateObs); measurement.setType(inputType); if (apptNo != null) { measurement.setAppointmentNo(Integer.parseInt(apptNo)); } else { measurement.setAppointmentNo(0); } measurement.setProviderNo(providerNo); measurementDao.persist(measurement); }
From source file:com.netcracker.tss.web.servlet.customer.CustomerOrderTaxiEditDeleteServlet.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from ww w .j a va2 s . c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); try { if (request.getParameter("addTo") != null) { addAddressTo(request); redirectToEdit(request, response, null); } else if (request.getParameter("addFrom") != null) { addAddressFrom(request); redirectToEdit(request, response, null); } else if (request.getParameter("deleteTo") != null || request.getParameter("deleteFrom") != null) { deleteAddress(request); redirectToEdit(request, response, null); } else { TaxiOrderBeanLocal taxiOrderBeanLocal = getTaxiOrderBean(request); Address addFrom = toAddress(request.getParameter("fromAddr"), request); Address addTo = toAddress(request.getParameter("toAddr"), request); PriceBeanLocal priceBean = getPriceBean(request); float distance = 0; double price = 0; try { MapBeanLocal mapBean = getMapBean(request); distance = mapBean.calculateDistance(request.getParameter("fromAddr"), request.getParameter("toAddr")); } catch (JSONException | IOException e) { e.printStackTrace(); } price = priceBean.calculatePrice(distance, DateParser.parseDate(request), (TaxiOrder) request.getSession().getAttribute("taxiOrder"), UserUtils.findCurrentUser()); request.getSession().removeAttribute("taxiOrder"); Date orderTime = DateParser.parseDate(request); orderTime.setYear(new Date().getYear()); taxiOrderBeanLocal.editTaxiOrderCustomer(taxiOrderId, addFrom, addTo, orderTime, distance, price); request.setAttribute("taxiOrderId", taxiOrderId); request.setAttribute("pageContent", "content/confirmation-updated.jsp"); request.getRequestDispatcher("/WEB-INF/views/customer/customer-template.jsp").forward(request, response); } } catch (Exception e) { Logger.getLogger(CustomerSoberServiceServlet.class.getName()).log(Level.SEVERE, e.getMessage(), e); String error = "Sorry, we can not make this order! Please, check all input parameters ad try again."; redirectToEdit(request, response, error); } }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.FormUpdateAction.java
public boolean doInput(FlowSheetItem item, EctMeasurementTypesBean mtypeBean, MeasurementFlowSheet mFlowsheet, String inputType, String mInstructions, String value, String comment, String date, String apptNo, HttpServletRequest request) {//from w w w . j a v a 2 s .c o m EctValidation ectValidation = new EctValidation(); ActionMessages errors = new ActionMessages(); String temp = request.getParameter("template"); String demographicNo = request.getParameter("demographic_no"); HttpSession session = request.getSession(); String providerNo = (String) session.getAttribute("user"); ResultSet rs; String regCharExp; String regExp = null; double dMax = 0; double dMin = 0; int iMax = 0; int iMin = 0; rs = ectValidation.getValidationType(inputType, mInstructions); regCharExp = ectValidation.getRegCharacterExp(); boolean valid = true; try { if (rs.next()) { dMax = rs.getDouble("maxValue"); dMin = rs.getDouble("minValue"); iMax = rs.getInt("maxLength"); iMin = rs.getInt("minLength"); regExp = oscar.Misc.getString(rs, "regularExp"); } rs.close(); String inputTypeDisplay = mtypeBean.getTypeDisplayName(); String inputValueName = item.getDisplayName(); String inputValue = value; String comments = comment; String dateObserved = date; java.util.Calendar calender = java.util.Calendar.getInstance(); String hour = Integer.toString(calender.get(java.util.Calendar.HOUR_OF_DAY)); String min = Integer.toString(calender.get(java.util.Calendar.MINUTE)); String second = Integer.toString(calender.get(java.util.Calendar.SECOND)); String dateEntered = dateObserved + " " + hour + ":" + min + ":" + second; if (!ectValidation.isInRange(dMax, dMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.range", inputTypeDisplay, Double.toString(dMin), Double.toString(dMax))); saveErrors(request, errors); valid = false; } if (!ectValidation.maxLength(iMax, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.maxlength", inputTypeDisplay, Integer.toString(iMax))); saveErrors(request, errors); valid = false; } if (!ectValidation.minLength(iMin, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.minlength", inputTypeDisplay, Integer.toString(iMin))); saveErrors(request, errors); valid = false; } if (!ectValidation.matchRegExp(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("errors.invalid", inputTypeDisplay)); saveErrors(request, errors); valid = false; } if (!ectValidation.isValidBloodPressure(regExp, inputValue)) { errors.add(inputValueName, new ActionMessage("error.bloodPressure")); saveErrors(request, errors); valid = false; } if (!ectValidation.isDate(dateObserved) && inputValue.compareTo("") != 0) { errors.add("Date", new ActionMessage("errors.invalidDate", inputTypeDisplay)); saveErrors(request, errors); valid = false; } if (valid) { comments = org.apache.commons.lang.StringEscapeUtils.escapeSql(comments); MsgStringQuote str = new MsgStringQuote(); Properties p = (Properties) session.getAttribute("providerBean"); String by = ""; if (p != null) { by = p.getProperty(providerNo, ""); } org.apache.commons.validator.GenericValidator gValidator = new org.apache.commons.validator.GenericValidator(); if (!GenericValidator.isBlankOrNull(inputValue)) { String[] dateComp = date.split("-"); Date dateObs = new Date(); dateObs.setYear(Integer.parseInt(dateComp[0]) - 1900); dateObs.setMonth(Integer.parseInt(dateComp[1]) - 1); dateObs.setDate(Integer.parseInt(dateComp[2])); Measurement measurement = new Measurement(); measurement.setDemographicId(Integer.parseInt(demographicNo)); measurement.setDataField(inputValue); measurement.setMeasuringInstruction(mInstructions); if (comments.equals("")) { comments = " "; } measurement.setComments(comments); measurement.setDateObserved(dateObs); measurement.setType(inputType); if (apptNo != null) { measurement.setAppointmentNo(Integer.parseInt(apptNo)); } else { measurement.setAppointmentNo(0); } measurement.setProviderNo(providerNo); //Find if the same data has already been entered into the system MeasurementDao measurementDao = (MeasurementDao) SpringUtils.getBean("measurementDao"); List<Measurement> measurements = measurementDao.findMatching(measurement); if (measurements.size() == 0) { //Write to the Dababase if all input values are valid measurementDao.persist(measurement); } rs.close(); } } } catch (SQLException e) { } return valid; }
From source file:com.androzic.plugin.tracker.SMSReceiver.java
private boolean parseJointechJT600(String text, Tracker tracker) { // Jointech JT600 // jeson,09-28 12:11:02,Speed:32km/h,Battery:80%,GPS:13,STANDARD, // http://maps.google.com/?q=22.549737N,114.076685E // 3110701703,09-28 12:11:02,Speed:0km/h,Charging,Base Station,STANDARD,Cell ID:4195,LAC:230 // 3110701703,04-24 22:44:33,Speed:0km/h,Battery:90%,GPS:8,STANDARD, // http://maps.google.com/?q=60.010245N,30.288323E // ALM,SOS,3110701703,09-28 12:11:02,Speed:32km/h,Battery:80%,GPS:13,STANDARD,http://maps.google.com/?q=22.549737N,114.076685E // http://fiddle.re/yv1h6 Pattern pattern = Pattern.compile( "(?:ALM,)?(?:(.*),)?([^,]+),([\\d\\-:\\s]+),(?:Speed:(\\d+)km/h,)?(?:Battery:(\\d+)%|Charging),[^,]+,[^,]+,(?:\\r?\\n)?http://maps\\.google\\.com/\\?q=([^,]+),(.+)"); Matcher m = pattern.matcher(text); if (!m.matches()) return false; String latitude = m.group(6); String longitude = m.group(7); double coords[] = CoordinateParser.parse(latitude + " " + longitude); if (Double.isNaN(coords[0]) || Double.isNaN(coords[1])) return false; tracker.latitude = coords[0];// ww w . j ava 2s. c om tracker.longitude = coords[1]; try { String speed = m.group(4); if (speed != null) tracker.speed = Double.parseDouble(speed) / 3.6; } catch (NumberFormatException ignore) { } String time = m.group(3); try { Date date = JointechDateFormatter.parse(time); Date now = new Date(); date.setYear(now.getYear()); tracker.time = date.getTime(); } catch (Exception e) { Log.e(TAG, "Date error", e); } String battery = m.group(5); try { tracker.battery = Integer.parseInt(battery); } catch (NumberFormatException ignore) { } tracker.imei = m.group(2); String message = m.group(1); if (!"".equals(message)) tracker.message = message; return true; }
From source file:biz.taoconsulting.dominodav.methods.PROPFIND.java
/** * (non-Javadoc)// w ww. j a v a 2 s . co m * * @see biz.taoconsulting.dominodav.methods.AbstractDAVMethod#action() */ @SuppressWarnings("deprecation") protected void action() throws Exception { // TODO: cleanup action method by // refactoring -- too messy boolean withoutChildren = true; // Resource only, no children IDAVRepository rep = this.getRepository(); IDAVResource resource; HttpServletResponse resp = this.getResp(); // Resource-Path is stripped by the repository name! String curPath = null; String curURI = null; try { curPath = (String) this.getHeaderValues().get("resource-path"); if (curPath == null || curPath.equals("")) { curPath = "/"; } // If Depth is missing it might throw an error, so we assume 0 then String depth = this.getHeaderValues().get("Depth"); if (depth != null && depth.equals("0")) { withoutChildren = true; } else { withoutChildren = false; } // uri is the unique identifier on the host includes servlet and // repository but not server curURI = (String) this.getHeaderValues().get("uri"); } catch (Exception e) { LOGGER.error(e); withoutChildren = true; // No recursive call to propfind in a error // condition } LOGGER.info("PROPFIND for path:[" + curPath + "] and URI:" + curURI); IDAVXMLResponse xr = DavXMLResponsefactory.getXMLResponse(null, false); if (this.redirectedFromGet) { // Determine the style String xsltStyle = null; if (rep instanceof DAVRepositoryMETA) { xsltStyle = WebDavManager.getManager(null).getRootPropfindStyle(); } else { xsltStyle = WebDavManager.getManager(null).getPropfindStyle(); } xr = DavXMLResponsefactory.getXMLResponse(xsltStyle, true); } else { xr = DavXMLResponsefactory.getXMLResponse(null, true); } // LOGGER.info("xr OK"); // xr = DavXMLResponsefactory.getXMLResponse(null, false); try { // Here we need to retrieve the path without the repository name! resource = rep.getResource(curURI, withoutChildren); if (resource == null) { // LOGGER.info("Resource is null"); this.setErrorMessage("<h1>404 - Resource not found</h1>", HttpServletResponse.SC_NOT_FOUND); String result = this.getErrorMessage(); resp.setContentLength(result.length()); PrintWriter out = resp.getWriter(); out.write(result); out.close(); } else { if (!resource.isCollection()) { // LOGGER.info("Resource is not a collection"); this.getResp().setHeader("ETag", resource.getETag()); } // Modified by EC // LOGGER.info("Further....."); java.util.Date dt = new java.util.Date(); this.getResp().setHeader("Last-Modified", dt.toGMTString()); this.getResp().setHeader("Cache-Control", "no-cache"); dt.setYear(70); this.getResp().setHeader("Expires", dt.toGMTString()); this.getResp().setHeader("Server", "Microsoft-IIS/6.0"); this.getResp().setHeader("Public-Extension", "http://schemas.microsoft.com/repl-2"); this.getResp().setHeader("MicrosoftSharePointTeamServices", "12.0.0.6210"); this.getResp().setHeader("Set-Cookie", "WSS_KeepSessionAuthenticated=80; path=" + curURI); // End Mody by EC xr.openTag("multistatus"); resource.addToDavXMLResponse(xr); xr.auxTag("username", rep.getCredentials().getUserName()); xr.addComment("Called method : PROPFIND"); xr.closeDocument(); // LOGGER.info("Close doc"); // Ugly hack: Domino closes connections on status 207 // and Win7 has a problem with it /* * if (this.redirectedFromGet || * this.cameFromWindows7webDAVredir(this.getReq())) { * this.setHTTPStatus(HttpServletResponse.SC_OK); * resp.setStatus(HttpServletResponse.SC_OK); } else { * this.setHTTPStatus(DAVProperties.STATUS_MULTIPART); * resp.setStatus(DAVProperties.STATUS_MULTIPART, * DAVProperties.STATUS_MULTIPART_STRING); } */ this.setHTTPStatus(DAVProperties.STATUS_MULTIPART); resp.setStatus(DAVProperties.STATUS_MULTIPART, DAVProperties.STATUS_MULTIPART_STRING); resp.setHeader("Connection", "keep-alive"); resp.setContentType(DAVProperties.TYPE_XML); // resp.setContentType("text/xml"); // resp.setHeader("content-encoding", "utf-8"); // resp.setContentLength(xr.getXMLBytes().length); // ServletOutputStream out = this.getOutputStream(); // out.write(xr.getXMLBytes()); // out.close(); String result = xr.toString(); resp.setContentLength(result.length()); PrintWriter out = resp.getWriter(); out.write(result); out.close(); } } catch (DAVNotFoundException exc) { // LOGGER.error(exc); this.setErrorMessage("<h1>404 - Resource not found</h1>", HttpServletResponse.SC_NOT_FOUND); String result = this.getErrorMessage(); resp.setContentLength(result.length()); PrintWriter out = resp.getWriter(); out.write(result); out.close(); } catch (IOException e) { // LOGGER.error(e); this.setErrorMessage("<h1>500 - We screwed up</h1><h2>" + e.getMessage() + "</h2>", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:org.amnesty.aidoc.search.AidocSearch.java
private StringBuffer buildStandardQuery(StringBuffer query, Map<String, List<String>> queryMap, String language) {/*from w ww. j a v a 2 s . co m*/ // Our query template. Prioritize new content. String tpl = "(" + "(" + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" + " AND @cm\\:from:[primRange]" + ") OR " // + "(" // + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" // + " AND @cm\\:from:[secRange]" // + ")^2 OR " + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" + ")" + ")"; Date from = new Date(); from.setYear(from.getYear() - 2); String primRange = ISO8601DateFormat.format(from) + " TO " + ISO8601DateFormat.format(new Date()); // from.setYear(from.getYear() - 4); // String secRange = ISO8601DateFormat.format(from) + " TO " // + ISO8601DateFormat.format(new Date()); // Compile regular expression Pattern pattern = Pattern.compile("primRange"); Matcher matcher = pattern.matcher(tpl); tpl = matcher.replaceAll(primRange); // pattern = Pattern.compile("secRange"); // matcher = pattern.matcher(tpl); // tpl = matcher.replaceAll(secRange); /* Process categories */ if (queryMap.containsKey("category")) { List<String> catValues = (List<String>) queryMap.get("category"); for (String category : catValues) { logger.debug("Search category: " + category); category = category.replace(" ", "_x0020_"); category = category.replace(",", "_x002c_"); query.append(" PATH:\"/cm:generalclassifiable//cm:" + category + "//*\" AND "); } } if (queryMap.containsKey("cat")) { List<String> catValues = (List<String>) queryMap.get("cat"); for (String category : catValues) { if (CategoryToClassMap.hm.containsKey(category.toUpperCase())) { String mappedClass = (String) CategoryToClassMap.hm.get(category.toUpperCase()); logger.debug("Mapping " + category + " to class: " + mappedClass); query.append(" @aicore\\:aiIndex:\""); query.append(mappedClass + "*"); query.append("\" AND"); } else logger.debug("No AiClass found for: " + category); } } /* Process keywords */ if (queryMap.containsKey("keywords")) { List<String> keywords = (List<String>) queryMap.get("keywords"); pattern = Pattern.compile("terms"); matcher = pattern.matcher(tpl); if (keywords.size() == 1) tpl = matcher.replaceAll(keywords.get(0)); else if (keywords.size() == 0) tpl = matcher.replaceAll("?"); else tpl = matcher.replaceAll("bad query"); query.append(tpl); } return query; }
From source file:ca.ualberta.cs.cmput301w15t04team04project.EditClaimActivity.java
/** * This function controls the MenuItem and shown as a on the scream.<br> * <ol>The MenuItem has the following functions: * <ul>//from w w w . j av a2 s . c o m * <li>The function will find all needed views by their id. * <li>The function will test the user chooses either adding or editing. * <li>If user chooses to add a claim, the class "AddThread" will be called * <li>Else if user chooses to edit a claim, the class "updateThread will be called * </ul> * </ol> * * @author Chenrui Lei * @author Ji Yang * @author Yufei Zhang * @version 1.1 * @since 2015-03-12 * @version 1.2 * @since 2015-03-20 */ @SuppressWarnings("deprecation") public void confirmClaim(MenuItem item) { EditText claimName = (EditText) findViewById(R.id.claimNameEditText); EditText description = (EditText) findViewById(R.id.descriptionEditText); EditText tag = (EditText) findViewById(R.id.tagEditText); DatePicker fromDatePicker = (DatePicker) findViewById(R.id.fromDatePicker); DatePicker toDatePicker = (DatePicker) findViewById(R.id.toDatePicker); Date sDate = new Date(); Date eDate = new Date(); String cName = claimName.getText().toString(); String cDescription = description.getText().toString(); String cTag = tag.getText().toString(); sDate.setDate(fromDatePicker.getDayOfMonth()); sDate.setMonth(fromDatePicker.getMonth()); sDate.setYear(fromDatePicker.getYear() - 1900); eDate.setDate(toDatePicker.getDayOfMonth()); eDate.setMonth(toDatePicker.getMonth()); eDate.setYear(toDatePicker.getYear() - 1900); if (addEditStatus == 0) { ArrayList<Item> cItem = new ArrayList<Item>(); ArrayList<String> cComments = new ArrayList<String>(); Claim claim = controller.setClaim(cName, cDescription, cTag, sDate, eDate, destinationList, user.getName(), cItem, cComments, claimLocation); Thread add = new AddThread(claim); add.start(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Claim claim = controller.setClaim(cName, cDescription, cTag, sDate, eDate, destinationList, user.getName(), items, comments, claimLocation); Thread update = new UpdateThread(claim); update.start(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:br.com.nverse.sac.controllers.NewClienteCtrl.java
public void setDatFim(ValueChangeEvent e) { Date d = (Date) e.getNewValue(); d.setYear(d.getYear() + 1); contrato.setDataFim(d); }