List of usage examples for java.util Date Date
public Date()
From source file:com.trio.breakFast.util.PrettyTimeUtil.java
public static void main(String[] args) { System.out.println(PrettyTimeUtil.prettyTime(new Date())); System.out.println(PrettyTimeUtil.prettyTime(123)); System.out.println(PrettyTimeUtil.prettySeconds(10)); System.out.println(PrettyTimeUtil.prettySeconds(61)); System.out.println(PrettyTimeUtil.prettySeconds(3661)); System.out.println(PrettyTimeUtil.prettySeconds(36611)); System.out.println(PrettyTimeUtil.prettySeconds(366111)); System.out.println(PrettyTimeUtil.prettySeconds(3661111)); System.out.println(PrettyTimeUtil.prettySeconds(36611111)); }
From source file:it.unibas.spicybenchmark.Main.java
public static void main(String[] args) { try {//from w w w. j a va 2 s.com String propertiesFile = args[0]; StringBuilder executionTimes = new StringBuilder("--- Execution times: ---\n"); Configuration configuration = DAOConfiguration.loadConfigurationFile(propertiesFile); IDataSourceProxy dataSource = new DAOXsd().loadSchema(configuration.getSchemaAbsolutePath()); LoadXMLFile xmlLoader = new LoadXMLFile(); Date beforeLoadingExpected = new Date(); INode expectedInstanceNode = xmlLoader.loadInstance(dataSource, configuration.getExpectedInstanceAbsolutePath()); Date afterLoadingExpected = new Date(); long loadingExpected = afterLoadingExpected.getTime() - beforeLoadingExpected.getTime(); executionTimes.append("Expected Instance loaded: ").append(loadingExpected).append(" ms\n"); INode translatedInstanceNode = xmlLoader.loadInstance(dataSource, configuration.getTranslatedInstanceAbsolutePath()); Date afterLoadingTranslated = new Date(); long loadingTranslated = afterLoadingTranslated.getTime() - afterLoadingExpected.getTime(); executionTimes.append("Translated Instance loaded: ").append(loadingTranslated).append(" ms\n"); List<String> exclusionList = new DAOExclusionList().loadExclusionList(dataSource, configuration.getExclusionsFileAbsolutePath()); Date startSpicyTime = new Date(); FeatureCollectionGenerator featureCollectionGenerator = new FeatureCollectionGenerator(); FeatureCollection featureCollection = featureCollectionGenerator.generate(expectedInstanceNode, translatedInstanceNode, exclusionList, dataSource, configuration); EvaluateSimilarity evaluator = new EvaluateSimilarity(); SimilarityResult similarityResult = evaluator.getSimilarityResult(featureCollection); similarityResult .setNumberOfNodesInExpectedInstance(new CalculateSize().getNumberOfNodes(expectedInstanceNode)); similarityResult.setNumberOfNodesInTranslatedInstance( new CalculateSize().getNumberOfNodes(translatedInstanceNode)); Date endSpicyTime = new Date(); long spicyExecTime = endSpicyTime.getTime() - startSpicyTime.getTime(); executionTimes.append("Spicy execution time: ").append(spicyExecTime).append(" ms\n"); if (configuration.isTreeEditDistanceValiente()) { Date startValiente = new Date(); similarityResult .setTreeEditDistanceValiente(new TreeEditDistanceGeneratorSimPack().compute(configuration)); Date stopValiente = new Date(); long valienteExecTime = stopValiente.getTime() - startValiente.getTime(); executionTimes.append("Valiente execution time: ").append(valienteExecTime).append(" ms\n"); } if (configuration.isTreeEditDistanceShasha()) { Date startShasha = new Date(); similarityResult.setTreeEditDistanceShasha( new TreeEditDistanceGenerator().computeTreeEditDistance(featureCollection)); Date stopShasha = new Date(); long shashaExecTime = stopShasha.getTime() - startShasha.getTime(); executionTimes.append("Shasha execution time: ").append(shashaExecTime).append(" ms\n"); } // similarityResult.setTopDownOrderedMaximumSubtree(new TopDownOrderedMaximumSubtreeGenerator().compute(configuration)); // similarityResult.setBottomUpMaximumSubtree(new BottomUpMaximumSubtreeGenerator().compute(configuration)); // similarityResult.setJaccard(new JaccardGenerator().compute(expectedInstanceNode, translatedInstanceNode)); Utility.printFinalLog(similarityResult, configuration, executionTimes.toString()); } catch (DAOException ex) { logger.error(ex); } }
From source file:SerializeJavaObjects_MySQL.java
public static void main(String args[]) throws Exception { Connection conn = null;// ww w . j av a 2s . c o m try { conn = getConnection(); System.out.println("conn=" + conn); conn.setAutoCommit(false); List<Object> list = new ArrayList<Object>(); list.add("This is a short string."); list.add(new Integer(1234)); list.add(new Date()); long objectID = writeJavaObject(conn, list); conn.commit(); System.out.println("Serialized objectID => " + objectID); List listFromDatabase = (List) readJavaObject(conn, objectID); System.out.println("[After De-Serialization] list=" + listFromDatabase); } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } }
From source file:ezbake.local.accumulo.LocalAccumulo.java
public static void main(String args[]) throws Exception { Logger logger = LoggerFactory.getLogger(LocalAccumulo.class); final File accumuloDirectory = Files.createTempDir(); int shutdownPort = 4445; MiniAccumuloConfig config = new MiniAccumuloConfig(accumuloDirectory, "strongpassword"); config.setZooKeeperPort(12181);//from w ww .j av a2s . c o m final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(config); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { accumulo.stop(); FileUtils.deleteDirectory(accumuloDirectory); System.out.println("\nShut down gracefully on " + new Date()); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }); accumulo.start(); printInfo(accumulo, shutdownPort); if (args.length > 0) { logger.info("Adding the following authorizations: {}", Arrays.toString(args)); Authorizations auths = new Authorizations(args); Instance inst = new ZooKeeperInstance(accumulo.getConfig().getInstanceName(), accumulo.getZooKeepers()); Connector client = inst.getConnector("root", new PasswordToken(accumulo.getConfig().getRootPassword())); logger.info("Connected..."); client.securityOperations().changeUserAuthorizations("root", auths); logger.info("Auths updated"); } // start a socket on the shutdown port and block- anything connected to this port will activate the shutdown ServerSocket shutdownServer = new ServerSocket(shutdownPort); shutdownServer.accept(); System.exit(0); }
From source file:com.bhc.test.ClientFormLogin.java
public static void main(String[] args) throws Exception { BasicCookieStore cookieStore = new BasicCookieStore(); CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); URI uri = null;/*from ww w. j av a 2 s.c o m*/ try { uri = new URIBuilder().setScheme("https").setHost("user.qunar.com").setPath("/captcha/api/image") .setParameter("k", "{en7mni(z").setParameter("p", "ucenter_login") .setParameter("c", "ef7d278eca6d25aa6aec7272d57f0a9a") .setParameter("t", String.valueOf(new Date().getTime())).build(); HttpGet httpget = new HttpGet(uri); CloseableHttpResponse response1 = httpclient.execute(httpget); try { HttpEntity entity = response1.getEntity(); System.out.println("Login form get: " + response1.getStatusLine()); EntityUtils.consume(entity); System.out.println("Initial set of cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response1.close(); } HttpUriRequest login = RequestBuilder.post().setUri(new URI("https://someportal/")) .addParameter("IDToken1", "username").addParameter("IDToken2", "password").build(); CloseableHttpResponse response2 = httpclient.execute(login); try { HttpEntity entity = response2.getEntity(); System.out.println("Login form get: " + response2.getStatusLine()); EntityUtils.consume(entity); System.out.println("Post logon cookies:"); List<Cookie> cookies = cookieStore.getCookies(); if (cookies.isEmpty()) { System.out.println("None"); } else { for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } } finally { response2.close(); } } finally { httpclient.close(); } }
From source file:org.dspace.app.cris.batch.ScriptDeleteRP.java
/** * Batch script to delete a RP. See the technical documentation for further * details./* w ww. ja va 2s . co m*/ */ public static void main(String[] args) { log.info("#### START DELETE: -----" + new Date() + " ----- ####"); Context dspaceContext = null; ApplicationContext context = null; try { dspaceContext = new Context(); dspaceContext.turnOffAuthorisationSystem(); DSpace dspace = new DSpace(); ApplicationService applicationService = dspace.getServiceManager() .getServiceByName("applicationService", ApplicationService.class); CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption("h", "help", false, "help"); options.addOption("r", "researcher", true, "RP id to delete"); options.addOption("s", "silent", false, "no interactive mode"); CommandLine line = parser.parse(options, args); if (line.hasOption('h')) { HelpFormatter myhelp = new HelpFormatter(); myhelp.printHelp("ScriptHKURPDelete \n", options); System.out.println("\n\nUSAGE:\n ScriptHKURPDelete -r <id> \n"); System.out.println("Please note: add -s for no interactive mode"); System.exit(0); } Integer rpId = null; boolean delete = false; boolean silent = line.hasOption('s'); Item[] items = null; if (line.hasOption('r')) { rpId = ResearcherPageUtils.getRealPersistentIdentifier(line.getOptionValue("r"), ResearcherPage.class); ResearcherPage rp = applicationService.get(ResearcherPage.class, rpId); if (rp == null) { if (!silent) { System.out.println("RP not exist...exit"); } log.info("RP not exist...exit"); System.exit(0); } log.info("Use browse indexing"); BrowseIndex bi = BrowseIndex.getBrowseIndex(plugInBrowserIndex); // now start up a browse engine and get it to do the work for us BrowseEngine be = new BrowseEngine(dspaceContext); String authKey = ResearcherPageUtils.getPersistentIdentifier(rp); // set up a BrowseScope and start loading the values into it BrowserScope scope = new BrowserScope(dspaceContext); scope.setBrowseIndex(bi); // scope.setOrder(order); scope.setFilterValue(authKey); scope.setAuthorityValue(authKey); scope.setResultsPerPage(Integer.MAX_VALUE); scope.setBrowseLevel(1); BrowseInfo binfo = be.browse(scope); log.debug("Find " + binfo.getResultCount() + "item(s) for the reseracher " + authKey); items = binfo.getItemResults(dspaceContext); if (!silent && rp != null) { System.out.println(MESSAGE_ONE); // interactive mode System.out.println("Attempting to remove Researcher Page:"); System.out.println("StaffNo:" + rp.getSourceID()); System.out.println("FullName:" + rp.getFullName()); System.out .println("the researcher has " + items.length + " relation(s) with item(s) in the HUB"); System.out.println(); System.out.println(QUESTION_ONE); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(isr); String answer = reader.readLine(); if (answer.equals("yes")) { delete = true; } else { System.out.println("Exit without delete"); log.info("Exit without delete"); System.exit(0); } } else { delete = true; } } else { System.out.println("\n\nUSAGE:\n ScriptHKURPDelete <-v> -r <RPid> \n"); System.out.println("-r option is mandatory"); log.error("-r option is mandatory"); System.exit(1); } if (delete) { if (!silent) { System.out.println("Deleting..."); } log.info("Deleting..."); cleanAuthority(dspaceContext, items, rpId); applicationService.delete(ResearcherPage.class, rpId); dspaceContext.complete(); } if (!silent) { System.out.println("Ok...Bye"); } } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); } finally { if (dspaceContext != null && dspaceContext.isValid()) { dspaceContext.abort(); } if (context != null) { context.publishEvent(new ContextClosedEvent(context)); } } log.info("#### END: -----" + new Date() + " ----- ####"); System.exit(0); }
From source file:net.anthonypoon.ngram.removespecial.Main.java
public static void main(String args[]) throws Exception { Options options = new Options(); options.addOption("a", "action", true, "Action"); options.addOption("i", "input", true, "input"); options.addOption("o", "output", true, "output"); options.addOption("c", "compressed", false, "is lzo zipped"); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); Configuration conf = new Configuration(); Job job = Job.getInstance(conf);/*from w w w . j a va 2s. co m*/ if (cmd.hasOption("compressed")) { job.setInputFormatClass(SequenceFileAsTextInputFormat.class); } job.setJarByClass(Main.class); //job.setInputFormatClass(SequenceFileAsTextInputFormat.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); switch (cmd.getOptionValue("action")) { case "list": job.setMapperClass(ListMapper.class); //job.setNumReduceTasks(0); job.setReducerClass(ListReducer.class); break; case "remove": job.setMapperClass(RemoveMapper.class); job.setReducerClass(RemoveReducer.class); break; default: throw new IllegalArgumentException("Missing action"); } String timestamp = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()); FileInputFormat.setInputPaths(job, new Path(cmd.getOptionValue("input"))); FileOutputFormat.setOutputPath(job, new Path(cmd.getOptionValue("output") + "/" + timestamp)); System.exit(job.waitForCompletion(true) ? 0 : 1); }
From source file:com.glaf.core.job.SysDataLogCreateTableJob.java
public static void main(String[] args) { Date date = DateUtils.getDateAfter(new Date(), 0); Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from w ww . j av a 2 s.c o m int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int daysOfMonth = DateUtils.getYearMonthDays(year, month + 1); calendar.set(year, month, daysOfMonth); int begin = getYearMonthDay(date); int end = getYearMonthDay(calendar.getTime()); for (int i = begin; i <= end; i++) { logger.debug(i); try { SysDataLogTableUtils.createTable("SYS_DATA_LOG_" + i); } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } }
From source file:com.mattbolt.javaray.JavaRay.java
public static void main(String[] args) { logger.info("Starting JavaRay Ray-Tracer by: Matt Bolt [mbolt35@gmail.com]"); ApplicationContext appContext = new ClassPathXmlApplicationContext("/JavaRayApplicationContext.xml"); JavaRayConfiguration configuration = (JavaRayConfiguration) appContext.getBean("javaRayConfiguration"); View view = new View(configuration); logger.debug(new StringBuilder("Configuration: [View: ").append(configuration.getViewWidth()).append("x") .append(configuration.getViewHeight()).append("], [Anti-Alias: ") .append(configuration.getAntiAlias()).append("]").toString()); Camera camera = new Camera(new Vector3(4, 3, 3)); Scene scene = getSceneThree(configuration); long t = new Date().getTime(); //new RayTracer(configuration).synchronousRender(scene, view, camera); final ImageTarget image = new ImageTarget("test", ImageTarget.ImageType.PNG, view.getWidth(), view.getHeight());/*w w w . j a v a 2 s .c o m*/ final WindowTarget window = new WindowTarget(1900, 0, view.getWidth(), view.getHeight()); new RayTracer(configuration).render(scene, view, camera, window); long totalTime = ((new Date().getTime() - t) / 1000); logger.debug("Complete! Took: " + totalTime + "seconds"); }
From source file:edu.asu.ca.kaushik.algorithms.structures.ColGrIterator2.java
/** * @param args//w ww.ja va 2 s .c o m */ public static void main(String[] args) { int t = 6; int k = 52; System.out.println("Time efficient:"); System.out.println(new Date()); ColGrIterator ci = new ColGrIterator1(t, k); long tot = 0; while (ci.hasNext()) { //System.out.println(ci.next()); ci.next(); tot++; } System.out.println(new Date()); System.out.println("total = " + tot); System.out.println(); System.out.println("Memory efficient:"); System.out.println(new Date()); ci = new ColGrIterator2(t, k); tot = 0; while (ci.hasNext()) { //System.out.println(ci.next()); ci.next(); tot++; } System.out.println(new Date()); System.out.println("total = " + tot); }