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.dataone.proto.trove.mn.service.v1.impl.MNCoreImpl.java
@Override public Log getLogRecords(Date fromDate, Date toDate, Event event, String pidFilter, Integer start, Integer count) throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented, ServiceFailure { int total = 0; // Send a properties file? as a string, until we come up with a query syntax to support by default. Properties searchProperties = new Properties(); if (fromDate != null) { searchProperties.setProperty("fromDate", fromDate.toString()); }//www . java 2 s . c om if (toDate != null) { searchProperties.setProperty("endTime", toDate.toString()); } if (event != null) { searchProperties.setProperty("event", event.xmlValue()); } if (pidFilter != null) { searchProperties.setProperty("pidFilter", pidFilter); } if (start != null) { searchProperties.setProperty("start", Integer.toString(start)); } else { searchProperties.setProperty("start", "0"); } if (count != null) { searchProperties.setProperty("count", Integer.toString(count)); } else { searchProperties.setProperty("count", "1000"); } Log log; try { log = solrIndex.search(searchProperties); } catch (Exception ex) { ex.printStackTrace(); throw new ServiceFailure("2312", "SolrIndex failed-" + ex.getMessage()); } return log; }
From source file:com.doculibre.constellio.stats.StatsCompiler.java
public synchronized void saveStats(SimpleSearch simpleSearch, SolrServer indexJournal, SolrServer indexCompile, QueryResponse res) throws SolrServerException, IOException { String collectionName = simpleSearch.getCollectionName(); String luceneQuery = simpleSearch.getLuceneQuery(); GregorianCalendar calendar = new GregorianCalendar(); Date time = new Date(); calendar.setTime(time);//from ww w .j ava 2s. c o m String query = luceneQuery; String escapedQuery = escape(query); long nbRes = res.getResults().getNumFound(); long qTime = res.getQTime(); String desplayDate = time.toString(); String searchDate = format(time); String queryWithParams = simpleSearch.toSimpleParams().toString(); SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", desplayDate + query); doc.addField("query", query); doc.addField("queryWithParams", queryWithParams); doc.addField("nbres", "" + nbRes); doc.addField("qtime", "" + qTime); doc.addField("dateaffiche", desplayDate); doc.addField("date", searchDate); doc.addField("recherche", "recherche"); doc.addField("collection", collectionName); UpdateRequest up = new UpdateRequest(); up.setAction(ACTION.COMMIT, true, true); up.add(doc); up.process(indexJournal); String compileId = "collection_" + collectionName + " id_" + escapedQuery; SolrQuery solrQuery = new SolrQuery(); // Requte Lucene solrQuery.setQuery("id:\"" + compileId + "\""); // nb rsultats par page solrQuery.setRows(15); // page de dbut solrQuery.setStart(0); QueryResponse qr = indexCompile.query(solrQuery); if (qr.getResults().getNumFound() > 0) { SolrDocument sd = qr.getResults().get(0); long freq = (Long) sd.getFieldValue("freq"); long click = (Long) sd.getFieldValue("click"); // indexCompile.deleteById(query); SolrInputDocument docCompile = new SolrInputDocument(); docCompile.addField("id", compileId); docCompile.addField("query", query); if (!((String) sd.getFieldValue("nbres")).equals("0")) { ConstellioSpringUtils.getAutocompleteServices().onQueryAdd(docCompile, query); } docCompile.addField("freq", freq + 1); docCompile.addField("nbres", "" + nbRes); docCompile.addField("recherche", "recherche"); docCompile.addField("collection", collectionName); if (nbRes == 0) { docCompile.addField("zero", "true"); } else { docCompile.addField("zero", "false"); } docCompile.addField("click", click); if (click == 0) { docCompile.addField("clickstr", "zero"); } else { docCompile.addField("clickstr", "notzero"); } up.clear(); up.setAction(ACTION.COMMIT, true, true); up.add(docCompile); up.process(indexCompile); } else { SolrInputDocument docCompile = new SolrInputDocument(); docCompile.addField("id", compileId); docCompile.addField("query", query); if (nbRes != 0) { ConstellioSpringUtils.getAutocompleteServices().onQueryAdd(docCompile, query); } docCompile.addField("freq", 1); docCompile.addField("recherche", "recherche"); docCompile.addField("collection", collectionName); docCompile.addField("nbres", "" + nbRes); if (nbRes == 0) { docCompile.addField("zero", "true"); } else { docCompile.addField("zero", "false"); } docCompile.addField("click", 0); docCompile.addField("clickstr", "zero"); up.clear(); up.setAction(ACTION.COMMIT, true, true); up.add(docCompile); up.process(indexCompile); } }
From source file:org.transdroid.core.service.AppUpdateService.java
@Override protected void onHandleIntent(Intent intent) { // Only run this service if app updates are handled via transdroid.org at all if (!navigationHelper.enableUpdateChecker()) return;//from ww w.j a v a 2 s . c om if (!connectivityHelper.shouldPerformBackgroundActions() || !systemSettings.checkForUpdates()) { Log.d(this, "Skip the app update service, as background data is disabled, the service is explicitly " + "disabled or we are not connected."); return; } Date lastChecked = systemSettings.getLastCheckedForAppUpdates(); Calendar lastDay = Calendar.getInstance(); lastDay.add(Calendar.DAY_OF_MONTH, -1); if (lastChecked != null && lastChecked.after(lastDay.getTime())) { Log.d(this, "Skip the update service, as we already checked the last 24 hours (or to be exact at " + lastChecked.toString() + ")."); return; } DefaultHttpClient httpclient = new DefaultHttpClient(); Random random = new Random(); try { // Retrieve what is the latest released app and search module versions String[] app = retrieveLatestVersion(httpclient, LATEST_URL_APP); String[] search = retrieveLatestVersion(httpclient, LATEST_URL_SEARCH); int appVersion = Integer.parseInt(app[0].trim()); int searchVersion = Integer.parseInt(search[0].trim()); // New version of the app? try { PackageInfo appPackage = getPackageManager().getPackageInfo(getPackageName(), 0); Log.d(this, "Local Transdroid is at " + appPackage.versionCode + " and the reported latest version is " + appVersion); if (appPackage.versionCode < appVersion) { // New version available! Notify the user. newNotification(getString(R.string.update_app_newversion), getString(R.string.update_app_newversion), getString(R.string.update_updateto, app[1].trim()), DOWNLOAD_URL_APP + "?" + Integer.toString(random.nextInt()), 90000); } } catch (NameNotFoundException e) { // Not installed... this can never happen since this Service is part of the app itself } // New version of the search module? try { PackageInfo searchPackage = getPackageManager().getPackageInfo("org.transdroid.search", 0); Log.d(this, "Local Transdroid Seach is at " + searchPackage.versionCode + " and the reported latest version is " + searchVersion); if (searchPackage.versionCode < searchVersion) { // New version available! Notify the user. newNotification(getString(R.string.update_search_newversion), getString(R.string.update_search_newversion), getString(R.string.update_updateto, search[1].trim()), DOWNLOAD_URL_SEARCH + "?" + Integer.toString(random.nextInt()), 90001); } } catch (NameNotFoundException e) { // The search module isn't installed yet at all; ignore and wait for the user to manually // install it (when the first search is initiated) } // Save that we successfully checked for app updates (and notified the user) // This prevents checking again for 1 day systemSettings.setLastCheckedForAppUpdates(new Date()); } catch (Exception e) { // Cannot check right now for some reason; log and ignore Log.d(this, "Cannot retrieve latest app or search module version code from the site: " + e.toString()); } }
From source file:bbct.android.common.activity.MainActivity.java
private void showSurvey1Dialog() { DateFormat dateFormat = DateFormat.getDateInstance(); Date today = new Date(); final String todayStr = dateFormat.format(today); if (!prefs.contains(SharedPreferenceKeys.INSTALL_DATE)) { prefs.edit().putString(SharedPreferenceKeys.INSTALL_DATE, todayStr).apply(); }/* ww w .java2s . co m*/ if (!prefs.contains(SharedPreferenceKeys.SURVEY1_DATE)) { String installDate = prefs.getString(SharedPreferenceKeys.INSTALL_DATE, today.toString()); try { Calendar cal = Calendar.getInstance(); cal.setTime(dateFormat.parse(installDate)); cal.add(Calendar.DATE, SURVEY_DELAY); if (today.after(cal.getTime())) { DialogUtil.showSurveyDialog(this, todayStr, R.string.survey1, SharedPreferenceKeys.SURVEY1_DATE, SURVEY1_URI); } } catch (ParseException e) { Log.d(TAG, "Error parsing install date"); e.printStackTrace(); } } }
From source file:com.ibm.xsp.webdav.DavXMLResponsePlain.java
public void dateTag(String TagName, Date date) { if (date == null) { return;// w w w. ja v a 2s . c o m } // "Sat, 26 Mar 2005 11:22:20 GMT"; String[] dateParsed = date.toString().split(" "); String timeZone = dateParsed[dateParsed.length - 2]; if (timeZone.equals("EEST")) { timeZone = "EET"; } if (timeZone.equals("EET") || timeZone.equals("ZE2")) { // if(TimeZone.getTimeZone(timeZone).getRawOffset()>0){ // LOGGER.info("Time zone="+timeZone); // LOGGER.info("Time offset="+ new Integer // (TimeZone.getTimeZone(timeZone).getRawOffset()).toString()); date = new Date(date.getTime() - TimeZone.getTimeZone(timeZone).getRawOffset()); timeZone = "GMT"; } String lastmodFormat = "EE', 'd' 'MMM' 'yyyy' 'HH':'mm':'ss"; //Locale.UK is the secret to make it work in Win7! SimpleDateFormat fmt = new SimpleDateFormat(lastmodFormat, Locale.UK); String datestring = fmt.format(date); this.simpleTag(TagName, datestring + " " + timeZone); }
From source file:it.cnr.isti.thematrix.configuration.LogST.java
/** * Print a startup message in the logfile, with info on version and date, java System properties * * @param version the program version//from ww w. j a v a 2 s . c o m * @param version2 the reference date as a string */ public void startupMessage(String version, String version2) { java.util.Date d = new java.util.Date(); StringBuilder welcomeMessage = new StringBuilder(); welcomeMessage.append(d.toString() + "********************************************* \n"); welcomeMessage.append(d.toString() + "* " + version + " released on " + version2 + " * \n"); welcomeMessage.append(d.toString() + "********************************************* \n"); welcomeMessage.append(d.toString() + "Java Runtime Properties \n\n"); welcomeMessage.append(d.toString() + System.getProperties().toString()); welcomeMessage.append(d.toString() + "\n\n"); welcomeMessage.append(d.toString() + "********************************************* \n"); welcomeMessage.append("-> Avvio test: " + d.toString() + "\n"); logP(0, welcomeMessage.toString()); }
From source file:org.nuxeo.apidoc.introspection.XMLWriter.java
public XMLWriter date(String name, Date value) throws IOException { return attr(name, value.toString()); }
From source file:com.abm.mainet.water.service.PlumberLicenseServiceImpl.java
@Override @Transactional//from w w w .ja va 2s .com public PlumLicenseRenewalSchDTO updatedUserTaskAndPlumberLicenseExecutionDetails(PlumberMaster master, TaskDefDto taskDefDto) { PlumLicenseRenewalSchDTO renewalSchDTO = new PlumLicenseRenewalSchDTO(); Long licNo = iChallanDAO.getSequence(WaterConstants.PlumberLicense.PLUM_MASTER_TABLE.MODULE, WaterConstants.PlumberLicense.PLUM_MASTER_TABLE.TABLE, WaterConstants.PlumberLicense.PLUM_MASTER_TABLE.COLUMN, master.getOrgid(), CFCConstants.RECEIPT_MASTER.Reset_Type, null); Date sysDate = UtilityService.getSQLDate(new Date()); String string = sysDate.toString(); String[] strings = string.split("-"); String yearPart = strings[0]; String paddingLicNo = String.format("%04d", Integer.parseInt(licNo.toString())); String orgId = master.getOrgid().toString(); String licNumber = orgId.concat(yearPart).concat(paddingLicNo); renewalSchDTO.setLicenseNo(String.valueOf(licNumber)); Long dependOnId = null; List<TbPlumRenewalScheduler> renewalSchedulers = plumberLicenseRepository .getPlumRenewalSchedulerDetails(master.getServiceId(), master.getOrgid()); for (TbPlumRenewalScheduler tbPlumRenewalScheduler : renewalSchedulers) { if (tbPlumRenewalScheduler.getTodate() == null) { dependOnId = tbPlumRenewalScheduler.getDependon(); break; } } Date date = new Date(); Calendar cal = Calendar.getInstance(); String toDateDependOn = CommonMasterUtility.getNonHierarchicalLookUpObject(dependOnId).getLookUpCode(); if (WaterConstants.PlumberLicense.TODATE_CALENDER_YEAR_WISE.equals(toDateDependOn)) { cal.setTime(date); int year = cal.get(Calendar.YEAR); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, 11); cal.set(Calendar.DAY_OF_MONTH, 31); Date endDate = cal.getTime(); renewalSchDTO.setLicenseToDate(Utility.dateToString(endDate)); renewalSchDTO.setLicenseFromDate(Utility.dateToString(date)); } else if (WaterConstants.PlumberLicense.TODATE_FINANCIAL_YEAR_WISE.equals(toDateDependOn)) { cal.setTime(date); int year = cal.get(Calendar.YEAR); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, 2); cal.set(Calendar.DAY_OF_MONTH, 31); Date endDate = cal.getTime(); renewalSchDTO.setLicenseToDate(Utility.dateToString(endDate)); renewalSchDTO.setLicenseFromDate(Utility.dateToString(date)); } else if (WaterConstants.PlumberLicense.TODATE_ON_LICENSE_DATE_WISE.equals(toDateDependOn)) { Date today = cal.getTime(); cal.add(Calendar.YEAR, 1); // to get previous year add -1 cal.add(Calendar.DAY_OF_MONTH, -1); Date nextYear = cal.getTime(); renewalSchDTO.setLicenseToDate(Utility.dateToString(nextYear)); renewalSchDTO.setLicenseFromDate(Utility.dateToString(today)); } master.setPlumLicNo(String.valueOf(licNo)); master.setPlumLicFromDate(Utility.stringToDate(renewalSchDTO.getLicenseFromDate())); master.setPlumLicToDate(Utility.stringToDate(renewalSchDTO.getLicenseToDate())); plumberLicenseRepository.updatedPlumberLicenseExecutionDetailsByDept(master); iTaskManagerService.updateUserTask(taskDefDto); return renewalSchDTO; }
From source file:com.bah.alter.PutGeowave.java
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { FlowFile flowFile = session.get();//w w w .j av a 2 s . c o m if (flowFile == null) { return; } System.out.println("PutGeowave processor executing "); System.out.println(context.getProperties()); System.out.println(flowFile.toString()); System.out.println(flowFile.getAttributes().toString()); System.out.println(flowFile); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); session.exportTo(flowFile, outputStream); System.out.println(outputStream.toString()); JSONObject jsonObject = new JSONObject(outputStream.toString()); if (jsonObject.has("coordinates")) { try { JSONObject coordinate = jsonObject.getJSONObject("coordinates"); System.out.println("has coordinate"); double longitude = 0; double latitude = 0; try { JSONArray point = coordinate.getJSONArray("coordinates"); longitude = point.getDouble(0); latitude = point.getDouble(1); } catch (JSONException e) { System.out.println("Couldn't get coordinates"); System.out.println(e.toString()); } System.out.println("lat: " + latitude + " long: " + longitude); String featureId = "0"; try { featureId = jsonObject.getString("id_str"); } catch (JSONException e) { System.out.println("failed to get id"); System.out.println(e.toString()); } Date date = new Date(); try { date = sf.parse(jsonObject.getString("created_at")); } catch (ParseException e) { System.out.println("Couldn't parse date"); System.out.println(e.toString()); } System.out.println("Date: " + date.toString()); try (IndexWriter indexWriter = geowaveDataStore.createIndexWriter(index)) { pointBuilder.set("geometry", GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude))); pointBuilder.set("TimeStamp", date); pointBuilder.set("Latitude", latitude); pointBuilder.set("Longitude", longitude); final SimpleFeature sft = pointBuilder.buildFeature(featureId); indexWriter.write(adapter, sft); System.out.println("wrote to accumulo"); session.transfer(flowFile, SUCCESS); } catch (final IOException | JSONException e) { System.out.println("Failed to write to accumulo"); session.transfer(flowFile, FAILURE); System.out.println(e.toString()); } } catch (JSONException e) { System.out.println("No coordinates"); session.transfer(flowFile, FAILURE); } } }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
public static void populateFileInfoViews(View v, OpenPath file) throws IOException { String apath = file.getAbsolutePath(); if (file instanceof OpenMediaStore) file = ((OpenMediaStore) file).getFile(); Date date = new Date(); if (file.lastModified() != null) date = new Date(file.lastModified()); TextView numDir = (TextView) v.findViewById(R.id.info_dirs_label); TextView numFile = (TextView) v.findViewById(R.id.info_files_label); TextView numSize = (TextView) v.findViewById(R.id.info_size); TextView numTotal = (TextView) v.findViewById(R.id.info_total_size); TextView numFree = (TextView) v.findViewById(R.id.info_free_size); //if (file.isDirectory()) { new CountAllFilesTask(numDir, numFile, numSize, numFree, numTotal).execute(file); //} else {/* ww w . ja v a 2s . co m*/ //numFile.setText("-"); //numDir.setText("-"); //} //((TextView)v.findViewById(R.id.info_name_label)).setText(file.getName()); ((TextView) v.findViewById(R.id.info_time_stamp)).setText(date.toString()); ((TextView) v.findViewById(R.id.info_path_label)).setText(file.getPath()); ((TextView) v.findViewById(R.id.info_read_perm)).setText(file.canRead() + ""); ((TextView) v.findViewById(R.id.info_write_perm)).setText(file.canWrite() + ""); ((TextView) v.findViewById(R.id.info_execute_perm)).setText(file.canExecute() + ""); if (file.isDirectory()) ((ImageView) v.findViewById(R.id.info_icon)).setImageResource(R.drawable.lg_folder); else ((ImageView) v.findViewById(R.id.info_icon)).setImageDrawable(getFileIcon(v.getContext(), file, false)); }