List of usage examples for java.util Date getTime
public long getTime()
From source file:net.sf.zekr.engine.search.tanzil.ZeroHighlighter.java
public static void main(String[] args) throws IOException { String s = ""; s = "";//from www. j a v a 2 s .c o m s = "-"; s = " "; s = "\" \" \"\" "; s = "- "; s = "\" \""; s = " "; s = " "; s = "\"\""; s = "???"; s = "."; s = "__"; System.out.println("Initialize AdvancedQuranTextSearch" + new Date()); // QuranText text = QuranText.getSimpleTextInstance(); TranslationData quranText = ApplicationConfig.getInstance().getTranslation().get("makarem"); PatternEnricher enricher = PatternEnricherFactory.getEnricher(quranText.getLanguage(), !quranText.isTranslation()); System.out.println("Enriched query: " + enricher.enrich(s)); AdvancedQuranTextSearch ats = new AdvancedQuranTextSearch(quranText, new SimpleSearchResultHighlighter(), new DefaultSearchScorer()); Date d1 = new Date(); System.out.println("Before search: " + d1); SearchResultModel res = ats.doSearch(s); Date d2 = new Date(); System.out.println("Matches: " + res.getClause()); System.out .println("After search: " + d2 + ". Took: " + (d2.getTime() - d1.getTime()) / 1000.0 + "seconds."); System.out.println(res.getTotalMatch() + " - " + res.getResults().size() + ":"); for (SearchResultItem sri : res.getResults()) { System.out.println(sri); } }
From source file:tasly.greathealth.jd.order.service.impl.JdCreateOrderServiceImpl.java
public static void main(final String[] args) throws JdException { final Date d = new Date(); final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println("" + df.format(d)); System.out.println("?" + df.format(new Date(d.getTime() - 2 * 24 * 60 * 60 * 1000))); System.out.println("?" + df.format(new Date(d.getTime() + 3 * 24 * 60 * 60 * 1000))); final String startExecuttime = TaslyThirdUtils.formatTime(d); final String endExecuttime = TaslyThirdUtils.addTime(d, 5); System.out.println("startExecuttime:" + startExecuttime + ",endExecuttime:" + endExecuttime); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Class.forName(DB_DRIVER);/*from w w w . ja v a 2s .c o m*/ Connection dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD); PreparedStatement preparedStatementInsert = null; PreparedStatement preparedStatementUpdate = null; String insertTableSQL = "INSERT INTO Person" + "(USER_ID, USERNAME, CREATED_BY, CREATED_DATE) VALUES" + "(?,?,?,?)"; String updateTableSQL = "UPDATE Person SET USERNAME =? " + "WHERE USER_ID = ?"; java.util.Date today = new java.util.Date(); dbConnection.setAutoCommit(false); preparedStatementInsert = dbConnection.prepareStatement(insertTableSQL); preparedStatementInsert.setInt(1, 9); preparedStatementInsert.setString(2, "101"); preparedStatementInsert.setString(3, "system"); preparedStatementInsert.setTimestamp(4, new java.sql.Timestamp(today.getTime())); preparedStatementInsert.executeUpdate(); preparedStatementUpdate = dbConnection.prepareStatement(updateTableSQL); preparedStatementUpdate.setString(1, "new string"); preparedStatementUpdate.setInt(2, 999); preparedStatementUpdate.executeUpdate(); dbConnection.commit(); dbConnection.close(); }
From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.historic.HistoricMarketDataOnDemandDemo.java
public static void main(String[] args) throws Exception { usage(args);//from www . j a v a 2 s . c o m final String url = args[0]; final String accessToken = args[1]; HistoricMarketDataProvider<String> historicMarketDataProvider = new OandaHistoricMarketDataProvider(url, accessToken); Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.getProperty("line.separator")); System.out.print("Instrument" + TradingConstants.COLON); String ccyPair = scanner.next(); TradeableInstrument<String> instrument = new TradeableInstrument<>(ccyPair.toUpperCase()); System.out.print( "Granularity" + ArrayUtils.toString(CandleStickGranularity.values()) + TradingConstants.COLON); CandleStickGranularity granularity = CandleStickGranularity.valueOf(scanner.next().toUpperCase()); System.out.print("Time Range Candles(t) or Last N Candles(n)?:"); String choice = scanner.next(); List<CandleStick<String>> candles = null; if ("t".equalsIgnoreCase(choice)) { System.out.print("Start Time(" + datefmtLabel + ")" + TradingConstants.COLON); String startStr = scanner.next(); Date startDt = sdf.parse(startStr); System.out.print(" End Time(" + datefmtLabel + ")" + TradingConstants.COLON); String endStr = scanner.next(); Date endDt = sdf.parse(endStr); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, new DateTime(startDt.getTime()), new DateTime(endDt.getTime())); } else { System.out.print("Last how many candles?" + TradingConstants.COLON); int n = scanner.nextInt(); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, n); } System.out.println(center("Time", timeColLen) + center("Open", priceColLen) + center("Close", priceColLen) + center("High", priceColLen) + center("Low", priceColLen)); System.out.println(repeat("=", timeColLen + priceColLen * 4)); for (CandleStick<String> candle : candles) { System.out.println(center(sdf.format(candle.getEventDate().toDate()), timeColLen) + formatPrice(candle.getOpenPrice()) + formatPrice(candle.getClosePrice()) + formatPrice(candle.getHighPrice()) + formatPrice(candle.getLowPrice())); } scanner.close(); }
From source file:edu.stanford.junction.simulator.ResponseTimeSimulator.java
public static void main(String[] argv) { ActivityScript desc = new ActivityScript(); JSONObject platform = new JSONObject(); try {/*from www .j a va 2s . c om*/ platform.put("android", "http://my.realsitic.url/for_android"); desc.addRolePlatform("simulator", "android", platform); } catch (Exception e) { } Date makeJuncTime = new Date(); XMPPSwitchboardConfig config = new XMPPSwitchboardConfig("prpl.stanford.edu"); JunctionMaker maker = JunctionMaker.getInstance(config); for (int actor_i = NumOfParticipant - 1; actor_i >= 0; actor_i--) { try { maker.newJunction(desc, new SimActorRT(makeJuncTime.getTime(), actor_i)); } catch (JunctionException e) { e.printStackTrace(System.err); } } while (true) { try { Thread.sleep(500000); } catch (Exception e) { } } }
From source file:io.anserini.IndexerCW09B.java
public static void main(String[] args) throws IOException, InterruptedException { Args clArgs = new Args(args); final String dataDir = clArgs.getString("-dataDir"); final String indexPath = clArgs.getString("-indexPath"); final int numThreads = clArgs.getInt("-threadCount"); clArgs.check();/* w ww . ja v a 2 s . co m*/ Date start = new Date(); IndexerCW09B indexer = new IndexerCW09B(dataDir, indexPath); int numIndexed = indexer.indexWithThreads(numThreads); System.out.println("Total " + numIndexed + " documents indexed in " + DurationFormatUtils.formatDuration(new Date().getTime() - start.getTime(), "HH:mm:ss")); }
From source file:edu.stanford.muse.email.CalendarUtil.java
public static void main(String args[]) { // tests for get date range Pair<Date, Date> p = getDateRange(2010, 10, 2011, 5); // 2010 nov through june 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, 10, 2011, -1); // 2010 Nov through end 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 2011, -1); // all of 2010 and 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 2010, -1); // all of 2010 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, -1, 2010, -1, -1); // all of 2010 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2007, -1, -1, 2007, 1, -1); // begin 2007 through end Feb (28th) System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2008, -1, -1, 2008, 1, -1); // begin 2008 through end Feb (29th) System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, 10, -1, 2011, 5, -1); // begin 2010 through end June 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 5, 2011, -1, 5); //begin 2010 through end of 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 5, 2011, 11, 25); //begin 2010 through end of 25th dec 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 5, 2011, 11, -1); // begin 2010 through end of 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(2010, -1, 5, 2011, 11, 31); //begin 2010 through end of 2011 System.out.println(p.getFirst() + " - " + p.getSecond()); p = getDateRange(-1, 1, 1, -1, 1, 1); // invalid years, returns null, null; System.out.println(p.getFirst() + " - " + p.getSecond()); Date d = new Date(); for (int i = 0; i < 100; i++) { d = quarterBeginning(d);/*from ww w .j a v a 2 s . co m*/ System.out.println(formatDateForDisplay(d)); d.setTime(d.getTime() - 1L); } }
From source file:lucene.IndexFiles.java
/** Index all text files under a directory. */ public static void main(String[] args) { String usage = "java org.apache.lucene.demo.IndexFiles" + " [-index INDEX_PATH] [-docs DOCS_PATH] [-update]\n\n" + "This indexes the documents in DOCS_PATH, creating a Lucene index" + "in INDEX_PATH that can be searched with SearchFiles"; String indexPath = "E:/index26"; // is DFR//from w w w .jav a2s . c om //2 is normal //3 is ib with h3 //4 is ib with h2 with porter stemmer //5 is ib with h2 with s stemmer //6 is ib with h2 without stemmer //7 is without stemmer without <p //8 is basic with all tags //9 is ib with h2 and stopwords without stemmer //10 like without ib, lower tags //11 like 10 with lower tags p, br and hr //12 like 11 with tags closed //13 is closed tags with punctuation replace and whitespace tokenizer with hyphen cared for //14 std tokenizer with hyphen taken cared for with stemmer //15 like 14 without stemming //16 like 15 with LMD //17 like 11 with LMD //18 with count of lower and upper delimiters of split //19 like 18 with (?i) to ignore case in all and valipas > 9 //20 with (?i) in all //21 is fresh 19 //22 is legalspans with LMD //23 is fresh 19 without 0 pass //24 is legalspans with InB2 //25 is 23 //26 is 25 with s stemmer and 0 //27 is legalspans demo of 50 passages //28 is modified legal span and fast //29 is 28 with s-stemming //30 is 28 with porter stemming String docsPath = "E:/documents/text"; boolean create = true; for (int i = 0; i < args.length; i++) { if ("-index".equals(args[i])) { indexPath = args[i + 1]; i++; } else if ("-docs".equals(args[i])) { docsPath = args[i + 1]; i++; } else if ("-update".equals(args[i])) { create = false; } } if (docsPath == null) { System.err.println("Usage: " + usage); System.exit(1); } final Path docDir = Paths.get(docsPath); if (!Files.isReadable(docDir)) { System.out.println("Document directory dhfndk '" + docDir.toAbsolutePath() + "' does not exist or is not readable, please check the path"); System.exit(1); } Date start = new Date(); try { System.out.println("Indexing to directory '" + indexPath + "'..."); Directory dir = FSDirectory.open(Paths.get(indexPath)); //Analyzer analyzer = new StandardAnalyzer(); //IndexWriterConfig iwc = new IndexWriterConfig(analyzer); StandardAnalyzer analyzer = new StandardAnalyzer(); //Directory dir = new RAMDirectory(); IndexWriterConfig iwc = new IndexWriterConfig(analyzer); /*IBSimilarity similarity = new IBSimilarity( new DistributionLL(),//1 //new DistributionSPL(),//2 new LambdaDF(),//1 //new LambdaTTF(), //2 new NormalizationH2());*/ /*DFRSimilarity similarity = new DFRSimilarity( ///////INB2 Similarity new BasicModelIn(), new AfterEffectL(), new NormalizationH1());*/ LMDirichletSimilarity similarity = new LMDirichletSimilarity();//////// LMD Model iwc.setSimilarity(similarity); IndexWriter writer = new IndexWriter(dir, iwc); if (create) { // Create a new index in the directory, removing any // previously indexed documents: iwc.setOpenMode(OpenMode.CREATE); } else { // Add new documents to an existing index: iwc.setOpenMode(OpenMode.CREATE_OR_APPEND); } System.out.println("Test 1"); // Optional: for better indexing performance, if you // are indexing many documents, increase the RAM // buffer. But if you do this, increase the max heap // size to the JVM (eg add -Xmx512m or -Xmx1g): // // iwc.setRAMBufferSizeMB(256.0); //IndexWriter writer = new IndexWriter(dir, iwc); System.out.println("Test 2"); indexDocs(writer, docDir); System.out.println("Test 3"); // NOTE: if you want to maximize search performance, // you can optionally call forceMerge here. This can be // a terribly costly operation, so generally it's only // worth it when your index is relatively static (ie // you're done adding documents to it): // // writer.forceMerge(1); writer.close(); Date end = new Date(); System.out.println(end.getTime() - start.getTime() + " total milliseconds"); } catch (IOException e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }
From source file:fr.iphc.grid.jobmanager.JobManager.java
/** * @param args//from w w w . j a v a 2s . c o m */ public static void main(String[] args) throws Exception { JobManager command = new JobManager(); CommandLine line = command.parse(args); ArrayList<File> JdlList = new ArrayList<File>(); Global.getOutputexecutor = Executors.newFixedThreadPool(10); Initialize init = new Initialize(); String SetupFile = "setup_vigrid.xml"; if (line.hasOption(OPT_SETUP)) { SetupFile = line.getOptionValue(OPT_SETUP); } if ((new File(SetupFile).isFile())) { init.GlobalSetup(SetupFile); } // Init Job if (line.hasOption(OPT_JOB)) { File file = new File(line.getOptionValue(OPT_JOB)); if ((file.isFile())) { JdlList.add(file); } else { System.err.println("The file " + file + " doesn't exist"); System.exit(-1); } } else { File file = new File(line.getOptionValue(OPT_FILEJOB)); if ((file.isFile())) { JdlList = init.InitJdl(file); } else { System.err.println("The file " + file + " doesn't exist"); System.exit(-1); } } if (line.hasOption(OPT_WAIT)) { Global.TIMEOUTWAIT = Integer.parseInt(line.getOptionValue(OPT_WAIT)); } if (line.hasOption(OPT_RUN)) { Global.TIMEOUTRUN = Integer.parseInt(line.getOptionValue(OPT_RUN)); } if (line.hasOption(OPT_END)) { Global.TIMEOUTEND = Integer.parseInt(line.getOptionValue(OPT_END)); } if (line.hasOption(OPT_LOGDISPLAY)) { Global.SEUILDISPLAYLOG = Float.parseFloat(line.getOptionValue(OPT_LOGDISPLAY)); } init.InitJob(JdlList); // Init Url Ce if (line.hasOption(OPT_QUEUE)) { Global.file = new File(line.getOptionValue(OPT_QUEUE)); } if (line.hasOption(OPT_BAD)) { Global.BadCe = new File(line.getOptionValue(OPT_BAD)); } if (line.hasOption(OPT_OPTIMIZETIMEOUTRUN)) { Global.OPTTIMEOUTRUN = false; } if (line.hasOption(OPT_CWD)) { File theDir = new File(line.getOptionValue(OPT_CWD)); if (!theDir.exists()) { if (!theDir.mkdirs()) { System.err.println("Working directory create failed: " + line.getOptionValue(OPT_CWD)); System.exit(-1); } } Global.Cwd = line.getOptionValue(OPT_CWD); } else { Global.Cwd = System.getProperty("user.dir"); } if (!(new File(Global.Cwd)).canWrite()) { System.err.println(" Write permission denied : " + Global.Cwd); System.exit(-1); } System.out.println("Current working directory : " + Global.Cwd); Date start = new Date(); init.PrintGlobalSetup(); init.InitUrl(Global.file); init.InitSosCe(); init.rmLoadFailed(Global.Cwd + "/loadFailed.txt"); System.out.println("CE: " + Global.ListUrl.size() + " Nb JOB: " + Global.ListJob.size() + " " + new Date()); if (Global.ListJob.size() < 6) { // pour obtenir rapport de 0.8 Global.OPTTIMEOUTRUN = false; } // check if we can connect to the grid try { SessionFactory.createSession(true); } catch (NoSuccessException e) { System.err.println("Could not connect to the grid at all (" + e.getMessage() + ")"); System.err.println("Aborting"); System.exit(0); } // Launch Tread Job JobThread st = new JobThread(Global.ListJob, Global.ListUrl); st.start(); LoggingThread logst = new LoggingThread(Global.ListJob, Global.ListUrl, Global.SEUILDISPLAYLOG); logst.start(); // create Thread Hook intercept kill +CNTL+C Thread hook = new Thread() { public void run() { try { for (Jdl job : Global.ListJob) { if (job.getJobId() != null) { JobThread.jobCancel(job.getJobId()); } } } catch (Exception e) { System.err.println("Thread Hook:\n" + e.getMessage()); } // give it a change to display final job state try { sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } }; Runtime.getRuntime().addShutdownHook(hook); // Integer timer = 180 * 60 * 1000; Date now = new Date(); // Boolean Fin = false; while ((!Global.END) && ((now.getTime() - start.getTime()) < Global.TIMEOUTEND * 60 * 1000)) { // TOEND // en // minutes now = new Date(); // int mb = 1024*1024; // Getting the runtime reference from system // Runtime runtime = Runtime.getRuntime(); // System.out.println("##### Heap utilization statistics [MB] // #####"); // Print used memory // System.out.println("Used Memory:" // + (runtime.totalMemory() - runtime.freeMemory()) / mb); // Print free memory // System.out.println("Free Memory:" // + runtime.freeMemory() / mb); // Print total available memory // System.out.println("Total Memory:" + runtime.totalMemory() / mb); // Print Maximum available memory // System.out.println("Max Memory:" + runtime.maxMemory() / mb); // // System.out.println("NB: "+nb_end); // if ((float)(runtime.totalMemory() - // runtime.freeMemory())/(float)runtime.maxMemory() > (float)0.3){ // System.out.println ("GC: "+(float)(runtime.totalMemory() - // runtime.freeMemory())/runtime.maxMemory()); // System.gc(); // }; sleep(15 * 1000); // in ms // System.gc(); // Fin=true; // for (Jdl job : Global.ListJob) { // if (job.getJob() != null) { // System.out.println("JOB: "+job.getId()+"\t"+job.getStatus()); // if (job.getStatus().compareTo("END")==0){ // ((JobImpl) job.getJob()).postStagingAndCleanup(); // System.out.println("END JOB: "+job.getId()); // job.setStatus("END"); // } // if (job.getStatus().compareTo("END")!=0){ // Fin=false; // } // System.out.println("JOB: "+job.getId()+"\t"+job.getStatus() + // "\t"+job.getFail()+"\t"+job.getNodeCe()); // } // } // while ((Global.END==0) && ((new // Date().getTime()-start.getTime())<timer)){ } // Boolean end_load=false; // while (!end_load){ // end_load=true; // for(Jdl job:Global.ListJob){ // if (job.getStatus().equals("LOAD")){ // end_load=false; // } // } // } System.out.println("END JOB: " + now); st.halt(); logst.halt(); Iterator<Url> k = Global.ListUrl.iterator(); while (k.hasNext()) { Url url = k.next(); System.out.println("URL: " + url.getUrl()); } Iterator<Jdl> m = Global.ListJob.iterator(); while (m.hasNext()) { Jdl job = m.next(); System.out.println( "JOB: " + job.getId() + "\t" + job.getFail() + "\t" + job.getStatus() + "\t" + job.getNodeCe()); } System.out.println(start + " " + new Date()); System.exit(0); }
From source file:edu.monash.merc.util.DMUtil.java
public static void main(String[] args) { Date date = GregorianCalendar.getInstance().getTime(); System.out.println("============ date: " + date); long time = date.getTime(); time -= 24 * 3600 * 1000;//from www.j a va2s. co m date.setTime(time); System.out.println("=========== date -1: " + date); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); Date yesterdayMidnight = cal.getTime(); System.out.println("============== yesterday midnight: " + yesterdayMidnight); String s = "1000"; String[] words = DMUtil.split(s); System.out.println("==== words size: " + words.length); for (String string : words) { if (StringUtils.isNotBlank(string)) { System.out.println(">" + string + "<"); } } char[] validchars = new char[] { '1', '0' }; boolean valid = StringUtils.containsOnly(s, validchars); System.out.println(" is valid: " + valid); String moreDelimitersStr = "test,simin\tmonash\n;hangzhou;\nmerc\ttpb"; String[] strResults = DMUtil.splitByDelims(moreDelimitersStr, ",", "\n", "\t", ";"); for (String st : strResults) { System.out.println("==== splited str: " + st); } String anotherStr = "CHST12\n" + "\t\n" + "LFNG\n" + "\t\n" + "BRAT1\n" + "\t\n" + "TTYH3\n" + "\t\n" + "GNA12\n" + "\t\n" + "CARD11\n" + "\t\n" + "AP5Z1\n" + "\t\n" + "PAPOLB\n" + "\t\n" + "WIPI2\n" + "\t\n" + "TNRC18" + "Simon Atest , testsss HTPD"; strResults = DMUtil.splitByDelims(anotherStr, ",", " ", "\n", "\t", ";"); for (String st : strResults) { System.out.println("==== splited str: " + st); } System.out.println("==== Service UUID :" + DMUtil.genUUIDWithPrefix("MON")); DMUtil.validateEmail("simon@aaa"); DMUtil.setDBSource(1000); DMUtil.setDBSource(101); DMUtil.setDBSource(111); DMUtil.setDBSource(10); DMUtil.setDBSource(1); DMUtil.setDBSource(100); System.out.println("================ match tl token : " + DMUtil.matchTLTokenPattern(1010)); String encodeStr = "redirect:$%7B%23req%3D%23context.get(%27com.opensymphony.xwork2.dispatcher.HttpServletRequest%27),%23a%3D%23req.getSession(),%23b%3D%23a.getServletContext(),%23c%3d%23b.getRealPath(%22/%22),%23fos%3dnew%20java.io.FileOutputStream(%23req.getParameter(%22p%22)),%23fos.write(%23req.getParameter(%22t%22).replaceAll(%22k8team%22,%20%22%3C%22).replaceAll(%22k8team%22,%20%22%3E%22).getBytes()),%23fos.close(),%23matt%3D%23context.get(%27com.opensymphony.xwork2.dispatcher.HttpServletResponse%27),%23matt.getWriter().println(%22OK..%22),%23matt.getWriter().flush(),%23matt.getWriter().close()%7D&t=a&p=%2Fsrv%2Fwebserver%2Ftomcat%2Fwebapps%2F1.txt"; try { System.out.println("======== { $ # ,' } = encode" + DMUtil.pathEncode("${#=(),'}")); System.out.println("==== decode url1 : " + DMUtil.pathDecode(encodeStr)); } catch (Exception ex) { ex.printStackTrace(); } }