List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:org.eurekastreams.server.persistence.mappers.db.StreamPopularHashTagsDbMapper.java
/** * Get the popular hashtags for the input Group/Person stream. * /*ww w. java 2 s . c o m*/ * @param inRequest * type of stream and unique key of the entity stream to fetch hashtags for * @return the list of popular hashtags */ public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager() .createQuery("SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()) .setParameter("activityDate", minActivityTime) .setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); }
From source file:com.esri.arcgis.android.samples.GeoJSONEarthquakeMap.GeoJSONEarthquakeMapActivity.java
private void getEarthquakeEvents() { int size;// w ww. j a va 2 s .c om String url = this.getResources().getString(R.string.earthquake_url); try { // Making the request and getting the response HttpClient client = new DefaultHttpClient(); HttpGet req = new HttpGet(url); HttpResponse res = client.execute(req); // Converting the response stream to string HttpEntity jsonentity = res.getEntity(); InputStream in = jsonentity.getContent(); String json_str = convertStreamToString(in); JSONObject jsonobj = new JSONObject(json_str); JSONArray feature_arr = jsonobj.getJSONArray("features"); SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.rgb(255, 128, 64), 15, SimpleMarkerSymbol.STYLE.CIRCLE); for (int i = 0; i < feature_arr.length(); i++) { // Getting the coordinates and projecting them to map's spatial // reference JSONObject obj_geometry = feature_arr.getJSONObject(i).getJSONObject("geometry"); double lon = Double.parseDouble(obj_geometry.getJSONArray("coordinates").get(0).toString()); double lat = Double.parseDouble(obj_geometry.getJSONArray("coordinates").get(1).toString()); Point point = (Point) GeometryEngine.project(new Point(lon, lat), SpatialReference.create(4326), mMapView.getSpatialReference()); JSONObject obj_properties = feature_arr.getJSONObject(i).getJSONObject("properties"); Map<String, Object> attr = new HashMap<String, Object>(); String place = obj_properties.getString("place").toString(); attr.put("Location", place); // Setting the size of the symbol based upon the magnitude float mag = Float.valueOf(obj_properties.getString("mag").toString()); size = getSizefromMag(mag); symbol.setSize(size); attr.put("Magnitude", mag); // Converting time from unix time to date format long timeStamp = Long.valueOf(obj_properties.getString("time").toString()); java.util.Date time = new java.util.Date((long) timeStamp); attr.put("Time ", time.toString()); attr.put("Rms ", obj_properties.getString("rms").toString()); attr.put("Gap ", obj_properties.getString("gap").toString()); // Add graphics to the graphic layer graphicsLayer.addGraphic(new Graphic(point, symbol, attr)); } } catch (ClientProtocolException e) { // Catch exceptions here e.printStackTrace(); } catch (IOException e) { // Catch exceptions here e.printStackTrace(); } catch (JSONException e) { // Catch exceptions here e.printStackTrace(); } }
From source file:com.wrapp.android.webimage.ImageDownloader.java
public static Date getServerTimestamp(final URL imageUrl) { Date expirationDate = new Date(); try {// w w w .jav a 2 s. c o m final String imageUrlString = imageUrl.toString(); if (imageUrlString == null || imageUrlString.length() == 0) { throw new Exception("Passed empty URL"); } LogWrapper.logMessage("Requesting image '" + imageUrlString + "'"); final HttpClient httpClient = new DefaultHttpClient(); final HttpParams httpParams = httpClient.getParams(); httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, CONNECTION_TIMEOUT_IN_MS); httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT_IN_MS); httpParams.setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, DEFAULT_BUFFER_SIZE); final HttpHead httpHead = new HttpHead(imageUrlString); final HttpResponse response = httpClient.execute(httpHead); Header[] header = response.getHeaders("Expires"); if (header != null && header.length > 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US); expirationDate = dateFormat.parse(header[0].getValue()); LogWrapper .logMessage("Image at " + imageUrl.toString() + " expires on " + expirationDate.toString()); } } catch (Exception e) { LogWrapper.logException(e); } return expirationDate; }
From source file:jp.g_aster.social.action.StampAction.java
/** * ????// w w w.j a va 2 s .c o m * @return */ @Form("stampDto") @Validation(rules = "stampCreateValidationRules", errorPage = "createStamp.jsp") @PreRenderMethod("getMemberFiles") public ActionResult create() { if (!this.isLogin()) { return new Redirect("/"); } //URL??? Date sysdate = new Date(); String md5Stamp = SocialUtil .getMD5String(stampDto.getMessage() + stampDto.getFacebookId() + sysdate.toString()); User user = (User) sessionScope.get("user"); stampDto.setAuthKey(md5Stamp); stampDto.setFacebookId(user.getId()); stampDto.setQrFileName(md5Stamp + ".jpg"); stampDto.setPageUrl("/stamp/getStamp?authKey=" + md5Stamp); stampDto.setImageUrl("/img/stamp/" + stampDto.getQrFileName()); stampService.makeStamp(stampDto); actionContext.getFlashMap().put("notice", "??????"); return new Redirect("/"); }
From source file:eu.scape_project.tb.wc.archd.test.WARCTest.java
/** * Test of nextKeyValue method, of class ArcRecordReader. */// w w w . ja v a 2 s. c om public void testNextKeyValue() throws Exception { RecordReader<Text, ArcRecord> recordReader = myArcF.createRecordReader(split, tac); recordReader.initialize(split, tac); int start = 1; while (recordReader.nextKeyValue()) { Text currKey = recordReader.getCurrentKey(); ArcRecord currValue = recordReader.getCurrentValue(); String currMIMEType = currValue.getMimeType(); String currType = currValue.getType(); String currURL = currValue.getUrl(); InputStream currStream = currValue.getContents(); String currContent; String myContentString; int myContentStringIndex; Date currDate = currValue.getDate(); int currHTTPrc = currValue.getHttpReturnCode(); int currLength = currValue.getLength(); System.out.println("KEY " + start + ": " + currKey + " MIME Type: " + currMIMEType + " Type: " + currType + " URL: " + currURL + " Date: " + currDate.toString() + " HTTPrc: " + currHTTPrc + " Length: " + currLength); // check example record 1 (first one and the header of the WARC file) if (start == 1) { //"myContentString" is arbitrary sting snipped of which we know that it exists in the content stream and of which we know the position in the stream. //We will search for the string int the content we read and compare it to the values we know. currContent = content2String(currStream); myContentString = "isPartOf: basic"; myContentStringIndex = currContent.indexOf(myContentString); //System.out.println("Search for: " + myContentString + "=> Index is: " + myContentStringIndex); assertEquals("ID not equal", "<urn:uuid:18cfb53d-1c89-4cc6-863f-e5535d430c95>", currKey.toString()); assertEquals("MIME Type not equal", "application/warc-fields", currMIMEType); assertEquals("Response type not equal", "warcinfo", currType); assertEquals("URL not equal", null, currURL); assertTrue("Date not correct", currDate.toString().startsWith("Wed May 22 12:27:40")); assertEquals("HTTPrc not equal", -1, currHTTPrc); assertEquals("Record length not equal", 374, currLength); assertEquals("Content mismatch", 202, myContentStringIndex); } start++; } }
From source file:eu.scape_project.tb.wc.archd.test.ARCTest.java
/** * Test of nextKeyValue method, of class ArcRecordReader. *//*from w w w. ja va 2s. c om*/ public void testNextKeyValue() throws Exception { RecordReader<Text, ArcRecord> recordReader = myArcF.createRecordReader(split, tac); recordReader.initialize(split, tac); int start = 1; while (recordReader.nextKeyValue()) { Text currKey = recordReader.getCurrentKey(); ArcRecord currValue = recordReader.getCurrentValue(); String currMIMEType = currValue.getMimeType(); String currType = currValue.getType(); String currURL = currValue.getUrl(); InputStream currStream = currValue.getContents(); String currContent; String myContentString; int myContentStringIndex; Date currDate = currValue.getDate(); int currHTTPrc = currValue.getHttpReturnCode(); int currLength = currValue.getLength(); System.out.println("KEY " + start + ": " + currKey + " MIME Type: " + currMIMEType + " Type: " + currType + " URL: " + currURL + " Date: " + currDate.toString() + " HTTPrc: " + currHTTPrc + " Length: " + currLength); // check example record 1 (first one and the header of the ARC file) if (start == 1) { //"myContentString" is arbitrary sting snipped of which we know that it exists in the content stream and of which we know the position in the stream. //We will search for the string int the content we read and compare it to the values we know. currContent = content2String(currStream); myContentString = "defaultgz_orderxml"; myContentStringIndex = currContent.indexOf(myContentString); //System.out.println("Search for: " + myContentString + "=> Index is: " + myContentStringIndex); assertEquals("ID not equal", "20130522085320/filedesc://3-2-20130522085320-00000-prepc2.arc", currKey.toString()); assertEquals("MIME Type not equal", "text/plain", currMIMEType); assertEquals("Response type not equal", "response", currType); assertEquals("URL not equal", "filedesc://3-2-20130522085320-00000-prepc2.arc", currURL); assertTrue("Date not correct", currDate.toString().startsWith("Wed May 22 08:53:20")); assertEquals("HTTPrc not equal", -1, currHTTPrc); assertEquals("Record length not equal", 1190, currLength); assertEquals("Content seems not to be correct", 531, myContentStringIndex); } start++; } }
From source file:controllers.UserReportController.java
@RequestMapping("/summarizedReport") public String getFullUserReport(Map<String, Object> model, @RequestParam(value = "dateCampaignFrom", required = false) Date dateCampaignFrom, @RequestParam(value = "dateCampaignTo", required = false) Date dateCampaignTo, HttpServletRequest request) throws Exception { lk.dataByUserAndCompany(request, model); Long cabinetId = (long) request.getSession().getAttribute(CABINET_ID_SESSION_NAME); if (dateCampaignFrom == null || dateCampaignFrom.toString().equals("")) { Calendar cl = Calendar.getInstance(); cl.set(Calendar.YEAR, Calendar.MONTH, 1, 0, 0, 0); dateCampaignFrom = cl.getTime(); }// w w w. j ava 2s .c o m if (dateCampaignTo == null || dateCampaignTo.toString().equals("")) { dateCampaignTo = new Date(); } LinkedHashMap<User, HashMap> reportMap = eventService .getUsersAndSuccessfulFailedPerformancesForReport(dateCampaignFrom, dateCampaignTo, cabinetId); model.put("reportMap", reportMap); model.put("errors", eventService.getErrors()); return "summarizedUserReport"; }
From source file:com.maskyn.fileeditorpro.dialogfragment.FileInfoDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View view = new DialogHelper.Builder(getActivity()).setTitle(R.string.info) .setView(R.layout.dialog_fragment_file_info).createSkeletonView(); //final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_file_info, null); ListView list = (ListView) view.findViewById(android.R.id.list); DocumentFile file = DocumentFile.fromFile( new File(AccessStorageApi.getPath(getActivity(), (Uri) getArguments().getParcelable("uri")))); if (file == null && Device.hasKitKatApi()) { file = DocumentFile.fromSingleUri(getActivity(), (Uri) getArguments().getParcelable("uri")); }//from w w w. j av a 2s . com // Get the last modification information. Long lastModified = file.lastModified(); // Create a new date object and pass last modified information // to the date object. Date date = new Date(lastModified); String[] lines1 = { getString(R.string.name), //getString(R.string.folder), getString(R.string.size), getString(R.string.modification_date) }; String[] lines2 = { file.getName(), //file.getParent(), FileUtils.byteCountToDisplaySize(file.length()), date.toString() }; list.setAdapter(new AdapterTwoItem(getActivity(), lines1, lines2)); return new AlertDialog.Builder(getActivity()).setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); }
From source file:com.jbombardier.console.charts.XYTimeChartPanel.java
public void saveChartData() { StringBuilder builder = new StringBuilder(); synchronized (seriesForSource) { Set<Long> xValues = new HashSet<Long>(); Collection<XYSeries> values = seriesForSource.values(); for (XYSeries xySeries : values) { List<XYDataItem> items = xySeries.getItems(); for (XYDataItem item : items) { double xValue = item.getXValue(); long xTimeValue = (long) xValue; xValues.add(xTimeValue); }/* w ww .j a v a2s. co m*/ } List<Long> xValuesList = new ArrayList<Long>(xValues); Collections.sort(xValuesList); Set<String> keys = seriesForSource.keySet(); builder.append("Time,"); for (String seriesKey : keys) { builder.append(seriesKey).append(","); } builder.append(newline); for (Long xValue : xValuesList) { Date date = new Date(xValue); builder.append(date.toString()); builder.append(","); for (String seriesKeys : keys) { XYSeries xySeries = seriesForSource.get(seriesKeys); Double d = findValue(xySeries, xValue); if (d != null) { builder.append(d); } builder.append(","); } builder.append(newline); } } String filename = chart.getTitle().getText() + ".csv"; File file = new File(filename); FileUtils.write(builder.toString(), file); Out.out("Data saved to '{}'", file.getAbsolutePath()); }
From source file:org.mobicents.applications.ussd.examples.http.push.HTTPPush.java
protected void addStatusEntry(String entry) { Date d = new Date(); d.setTime(System.currentTimeMillis()); StringBuilder sb = new StringBuilder(); sb.append(d.toString()).append(">").append(entry); sb.append("\n"); sb.append("---------------------------------"); logger.info(sb.toString());//from w w w . java 2 s. co m this.status.append(sb.toString().replaceAll("<", "-").replaceAll(">", "-")); }