List of usage examples for java.util Date getSeconds
@Deprecated public int getSeconds()
From source file:eionet.meta.exports.ods.Ods.java
/** * Returns date.// www .j a v a 2 s. c om * * @param timestamp * time stamp * * @return date as a string */ public static String getDate(long timestamp) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth() + 1); month = (month.length() < 2) ? ("0" + month) : month; String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; String hours = String.valueOf(date.getHours()); hours = (hours.length() < 2) ? ("0" + hours) : hours; String minutes = String.valueOf(date.getMinutes()); minutes = (minutes.length() < 2) ? ("0" + minutes) : minutes; String seconds = String.valueOf(date.getSeconds()); seconds = (seconds.length() < 2) ? ("0" + seconds) : seconds; String time = year; time = time + "-" + month; time = time + "-" + day; time = time + "T" + hours; time = time + ":" + minutes; time = time + ":" + seconds; return time; }
From source file:de.micromata.genome.gwiki.plugin.rogmp3_1_0.Track.java
public long getTime() { String l = get(LENGTH);//from w ww .j av a 2s. c o m if (StringUtils.isBlank(l) == true) { return 0; } try { Date d = trackTimeFormat.get().parse(l); return d.getSeconds() + d.getMinutes() * 60 + d.getHours() * 3600; } catch (ParseException e) { System.out.println("cannot parse length: " + l); return 0; } }
From source file:org.openmrs.web.servlet.ShowGraphServletTest.java
/** * @see ShowGraphServlet#getToDate(String) *//* w ww.j av a2 s .c o m*/ @Test @Verifies(value = "should set hour minute and second to zero", method = "getToDate(String)") public void getToDate_shouldSetHourMinuteAndSecondToZero() throws Exception { Date toDate = new ShowGraphServlet().getToDate(Long.toString(new Date().getTime())); Assert.assertEquals(0, toDate.getHours()); Assert.assertEquals(0, toDate.getMinutes()); Assert.assertEquals(0, toDate.getSeconds()); }
From source file:playground.jbischoff.carsharing.data.VBBRouteCatcher.java
private void run(Coord from, Coord to, long departureTime) { Locale locale = new Locale("en", "UK"); String pattern = "###.000000"; DecimalFormat df = (DecimalFormat) NumberFormat.getNumberInstance(locale); df.applyPattern(pattern);/*from w w w . j ava2 s .c o m*/ // Construct data //X&Y coordinates must be exactly 8 digits, otherwise no proper result is given. They are swapped (x = long, y = lat) //Verbindungen 1-n bekommen; Laufweg, Reisezeit & Umstiege ermitteln String text = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" + "<ReqC accessId=\"JBischoff2486b558356fa9b81b1rzum\" ver=\"1.1\" requestId=\"7\" prod=\"SPA\" lang=\"DE\">" + "<ConReq>" + "<ReqT date=\"" + VBBDAY.format(departureTime) + "\" time=\"" + VBBTIME.format(departureTime) + "\">" + "</ReqT>" + "<RFlags b=\"0\" f=\"1\" >" + "</RFlags>" + "<Start>" + "<Coord name=\"START\" x=\"" + df.format(from.getY()).replace(".", "") + "\" y=\"" + df.format(from.getX()).replace(".", "") + "\" type=\"WGS84\"/>" + "<Prod prod=\"1111000000000000\" direct=\"0\" sleeper=\"0\" couchette=\"0\" bike=\"0\"/>" + "</Start>" + "<Dest>" + "<Coord name=\"ZIEL\" x=\"" + df.format(to.getY()).replace(".", "") + "\" y=\"" + df.format(to.getX()).replace(".", "") + "\" type=\"WGS84\"/>" + "</Dest>" + "</ConReq>" + "</ReqC>"; PostMethod post = new PostMethod("http://demo.hafas.de/bin/pub/vbb/extxml.exe/"); post.setRequestBody(text); post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1"); HttpClient httpclient = new HttpClient(); try { int result = httpclient.executeMethod(post); // Display status code // System.out.println("Response status code: " + result); // Display response // System.out.println("Response body: "); // System.out.println(post.getResponseBodyAsString()); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(post.getResponseBodyAsStream()); if (writeOutput) { BufferedWriter writer = IOUtils.getBufferedWriter(filename); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //initialize StreamResult with File object to save to file StreamResult res = new StreamResult(writer); DOMSource source = new DOMSource(document); transformer.transform(source, res); writer.flush(); writer.close(); } Node connectionList = document.getFirstChild().getFirstChild().getFirstChild(); NodeList connections = connectionList.getChildNodes(); int amount = connections.getLength(); for (int i = 0; i < amount; i++) { Node connection = connections.item(i); Node overview = connection.getFirstChild(); ; while (!overview.getNodeName().equals("Overview")) { overview = overview.getNextSibling(); } System.out.println(overview.getChildNodes().item(3).getTextContent()); int transfers = Integer.parseInt(overview.getChildNodes().item(3).getTextContent()); String time = overview.getChildNodes().item(4).getFirstChild().getTextContent().substring(3); System.out.println(time); Date rideTime = VBBDATE.parse(time); int seconds = rideTime.getHours() * 3600 + rideTime.getMinutes() * 60 + rideTime.getSeconds(); System.out.println(seconds + "s; transfers: " + transfers); if (seconds < this.bestRideTime) { this.bestRideTime = seconds; this.bestTransfers = transfers; } } } catch (Exception e) { this.bestRideTime = -1; this.bestTransfers = -1; } finally { // Release current connection to the connection pool // once you are done post.releaseConnection(); post.abort(); } }
From source file:de.janrenz.app.mediathek.ArdMediathekProvider.java
@Override public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) { String url = ""; String queryparam = uri.getQueryParameter("timestamp"); ;//from ww w. j a v a2 s .co m Integer timestamp = null; if (queryparam == null) { Date dt = new Date(); timestamp = dt.getSeconds(); } else { timestamp = Integer.parseInt(queryparam); } String queryparammethod = uri.getQueryParameter("method"); if (queryparammethod == null) { queryparammethod = "list"; url = "http://m-service.daserste.de/appservice/1.4.2/video/list/" + timestamp + "?func=getVideoList&unixTimestamp=" + timestamp; } else if (queryparammethod.equalsIgnoreCase("search")) { // url = /appservice/1.4.1/search/heiter/0/25?func=getSearchResultList&searchPattern=heiter&searchOffset=0&searchLength=25 String searchQuery = uri.getQueryParameter("query"); //!TODO make this url safe url = "http://m-service.daserste.de/appservice/1.4.2/search/" + URLEncoder.encode(searchQuery) + "/0/50?func=getSearchResultList&searchPattern=" + URLEncoder.encode(searchQuery) + "&searchOffset=0&searchLength=50"; } else if (queryparammethod.equalsIgnoreCase("broadcast")) { url = "http://m-service.daserste.de/appservice/1.4.2/broadcast/current/" + timestamp + "?func=getCurrentBroadcast&unixTimestamp=" + timestamp; } else { // oh oh } String queryparamReload = uri.getQueryParameter("reload"); String queryExtReload = ""; if (queryparamReload != null) { queryExtReload = "&reload=" + Math.random(); } String result = ""; result = readJSONFeed(url); MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "title", "subtitle", "image", "extId", "startTime", "startTimeAsTimestamp", "isLive" }); if (result == "") { return cursor; } if (queryparammethod.equalsIgnoreCase("broadcast")) { cursor = (MatrixCursor) processResultForBroadcast(result); } else if (queryparammethod.equalsIgnoreCase("search")) { cursor = (MatrixCursor) processResultForList(result, true); } else { Boolean orderParam = false; try { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); Boolean reverse = sharedPref.getBoolean(SettingsActivity.REVERSE_LIST_ORDER, false); //reverse is menat by user perspective here, by default its false if (reverse == true) { orderParam = true; } } catch (Exception e) { // use the default if we cant fetch it } //Log.e("order Param", orderParam.toString()); cursor = (MatrixCursor) processResultForList(result, orderParam); } return (Cursor) cursor; }
From source file:com.dare2date.externeservice.lastfm.LastfmAPI.java
/** * Adds date data to an event./* w w w.j a v a 2 s. c o m*/ * @param eventdata * @param event */ private void addDateToEventFromJSONData(JSONObject eventdata, LastfmEvent event) { try { Calendar date = Calendar.getInstance(); Date _date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.ENGLISH) .parse(eventdata.get("startDate").toString()); date.set(_date.getYear(), _date.getMonth(), _date.getDay(), _date.getHours(), _date.getMinutes(), _date.getSeconds()); event.setStartDate(date); } catch (ParseException e) { e.printStackTrace(); } }
From source file:com.ebay.pulsar.collector.simulator.Simulator.java
private void adjustBatchSize() { Date date = new Date(); int secondValue = date.getSeconds(); m_batchSize = trafficVolume(minVolume, peakTimes, secondValue); }
From source file:tds.tdsadmin.web.backingbean.DefaultBacking.java
public String getTime(Date date) { if (date != null) return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); else// w w w. jav a 2s . co m return null; }
From source file:md.ibanc.rm.controllers.request.RequestCustomersController.java
@RequestMapping(value = "/register/customer", method = RequestMethod.POST) public ResponseEntity<CustomersDetails> registerCustomer(@Valid @RequestBody RegisterForm registerForm, BindingResult bindingResult, HttpServletRequest request) { if (bindingResult.hasFieldErrors()) { return showFieldErrors(bindingResult); }//from ww w .j av a 2s . c om Customers customers = customersService.findCustomersByEmail(registerForm.getEmail()); Status status = statusService.findStatusByName(StatusCodeConst.ACTIVE); City city = cityService.findCityByName(registerForm.getCity()); Languages languages = languagesService.findLanguagesByShortName(registerForm.getLang()); if (customers == null) { customers = new Customers(); Date dateNow = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dateNow); calendar.add(Calendar.MONTH, 1); Date dateExpire = calendar.getTime(); int seconds = dateNow.getSeconds(); String hashPassword = UtilHashMD5 .createMD5Hash(FormatPassword.CreatePassword(seconds, registerForm.getPassword())); customers.setCity(city); customers.setFirstName(registerForm.getFirsName()); customers.setLastName(registerForm.getLastName()); customers.setPersonalId(registerForm.getPersonalId()); customers.setEmail(registerForm.getEmail()); customers.setUserName(registerForm.getUserName()); customers.setPassword(hashPassword); customers.setLasstAcces(null); customers.setStatus(status); customers.setLanguages(languages); customers.setAdress(registerForm.getAdress()); customers.setPhone(registerForm.getPhone()); customers.setWebsite(registerForm.getWebSite()); customers.setExpirePassword(dateExpire); customers.setUnSuccessfulAtempst(0); customers.setEmailCode(null); customers.setRegisteDate(dateNow); customersService.save(customers); } return new ResponseEntity<>(HttpStatus.OK); }
From source file:com.netflix.spinnaker.front50.model.GcsStorageService.java
@VisibleForTesting public void scheduleWriteLastModified(String daoTypeName) { Date when = new Date(); when.setSeconds(when.getSeconds() + 2); GcsStorageService service = this; Runnable task = new Runnable() { public void run() { // Release the scheduled update lock, and perform the actual update scheduledUpdateLock(daoTypeName).set(false); log.info("RUNNING {}", daoTypeName); service.writeLastModified(daoTypeName); }//from w ww . ja va 2 s .co m }; if (scheduledUpdateLock(daoTypeName).compareAndSet(false, true)) { log.info("Scheduling deferred update {} timestamp.", daoTypeName); taskScheduler.schedule(task, when); } }