List of usage examples for java.util Date Date
public Date()
From source file:com.apress.prospringintegration.springbatch.integration.IntegrationMain.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("integration.xml"); context.start();// www .ja v a2s . c om MessageChannel launchChannel = context.getBean("launchChannel", MessageChannel.class); QueueChannel statusChannel = context.getBean("statusChannel", QueueChannel.class); Job job = (Job) context.getBean("importData"); JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); jobParametersBuilder.addDate("date", new Date()); jobParametersBuilder.addString("input.file", "registrations"); JobParameters jobParameters = jobParametersBuilder.toJobParameters(); JobLaunchRequest jobLaunchRequest = new JobLaunchRequest(job, jobParameters); launchChannel.send(MessageBuilder.withPayload(jobLaunchRequest).build()); Message<JobExecution> statusMessage = (Message<JobExecution>) statusChannel.receive(); JobExecution jobExecution = statusMessage.getPayload(); System.out.println(jobExecution); System.out.println("Exit status: " + jobExecution.getExitStatus().getExitCode()); JobInstance jobInstance = jobExecution.getJobInstance(); System.out.println("job instance Id: " + jobInstance.getId()); }
From source file:hydrograph.server.service.HydrographServiceClient.java
public static void main(String[] args) { HydrographServiceClient client = new HydrographServiceClient(); try {/*from w w w. j av a 2 s .c o m*/ System.out.println("+++ Start: " + new Timestamp((new Date()).getTime())); // client.calltoReadService(); // client.calltoFilterService(); // client.calltoReadMetastore(); client.chcekConnectionStatus(); // client.calltoDeleteLocalDebugService(); System.out.println("done:"); System.out.println("+++ End: " + new Timestamp((new Date()).getTime())); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.payne.test.DateFormateTest.java
public static void main(String[] args) throws ParseException { // String a = null; // boolean ismmediated = a == null || DateUtils.parseDate(null,"yyyy-MM-dd HH:mm").compareTo(new Date()) <= 0; // //from w w w .j a v a 2 s .com // System.out.println(""+ismmediated); // System.out.println(""+System.currentTimeMillis()); // // String randomNum = String.valueOf(Math.random()); // randomNum = randomNum.replace(".", ""); // randomNum = randomNum.substring(0, 8); // // System.out.println(""+Integer.valueOf(randomNum.toString())); // // Integer a = 1000000000; // BigDecimal b = new BigDecimal("3000000000"); // System.out.println(""+b.longValue()); // System.out.println(""+b.intValue()); SimpleDateFormat sdf = new SimpleDateFormat(""); // Calendar c = Calendar.getInstance(); // c.setTime(new Date()); // c.set(Calendar.MINUTE, 0); // c.set(Calendar.SECOND, 0); // c.set(Calendar.MILLISECOND, 0); // System.out.println(sdf.format(new Date())); }
From source file:edu.nju.cs.inform.jgit.unfinished.UpdateIndex.java
public static void main(String[] args) throws IOException, GitAPIException { try (final Repository repo = CookbookHelper.openJGitCookbookRepository()) { try (final Git git = new Git(repo)) { final String testFile = "README.md"; // Modify the file FileUtils.write(new File(testFile), new Date().toString()); System.out.println("Modified files: " + getModifiedFiles(git)); new AssumeChangedCommand(repo, testFile, true).call(); System.out.println("Modified files after assume-changed: " + getModifiedFiles(git)); new AssumeChangedCommand(repo, testFile, false).call(); System.out.println("Modified files after no-assume-changed: " + getModifiedFiles(git)); git.checkout().addPath(testFile).call(); System.out.println("Modified files after reset: " + getModifiedFiles(git)); }/*from w w w.j a va 2 s .c o m*/ } }
From source file:org.sourceopen.hadoop.hbase.replication.server.Consumer.java
public static void main(String args[]) { try {/*from w ww . j a v a2 s . com*/ final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(SPRING_PATH); // ? Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { context.stop(); context.close(); LOG.info("Consumer server stopped"); System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " Consumer server stoped"); } catch (Throwable t) { LOG.error("Fail to stop consumer server: ", t); } synchronized (Consumer.class) { running = false; Consumer.class.notify(); } } }); Configuration conf = HBaseConfiguration.create(); conf.addResource(ConsumerConstants.COMMON_CONFIG_FILE); conf.addResource(ConsumerConstants.CONSUMER_CONFIG_FILE); Consumer.start(conf); LOG.info("Consumer server started"); System.out.println( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " Consumer server started"); } catch (Throwable t) { LOG.error("Fail to start consumer server: ", t); System.exit(-1); } synchronized (Consumer.class) { while (running) { try { Consumer.class.wait(); } catch (Throwable t) { LOG.error("Consumer server got runtime errors: ", t); } } } }
From source file:com.joliciel.lefff.Lefff.java
/** * @param args/* w w w .java2s . c om*/ */ public static void main(String[] args) throws Exception { long startTime = (new Date()).getTime(); String command = args[0]; String memoryBaseFilePath = ""; String lefffFilePath = ""; String posTagSetPath = ""; String posTagMapPath = ""; String word = null; List<String> categories = null; int startLine = -1; int stopLine = -1; boolean firstArg = true; for (String arg : args) { if (firstArg) { firstArg = false; continue; } int equalsPos = arg.indexOf('='); String argName = arg.substring(0, equalsPos); String argValue = arg.substring(equalsPos + 1); if (argName.equals("memoryBase")) memoryBaseFilePath = argValue; else if (argName.equals("lefffFile")) lefffFilePath = argValue; else if (argName.equals("startLine")) startLine = Integer.parseInt(argValue); else if (argName.equals("stopLine")) stopLine = Integer.parseInt(argValue); else if (argName.equals("posTagSet")) posTagSetPath = argValue; else if (argName.equals("posTagMap")) posTagMapPath = argValue; else if (argName.equals("word")) word = argValue; else if (argName.equals("categories")) { String[] parts = argValue.split(","); categories = new ArrayList<String>(); for (String part : parts) { categories.add(part); } } else throw new RuntimeException("Unknown argument: " + argName); } final LefffServiceLocator locator = new LefffServiceLocator(); locator.setDataSourcePropertiesFile("jdbc-live.properties"); TalismaneServiceLocator talismaneServiceLocator = TalismaneServiceLocator.getInstance(); final LefffService lefffService = locator.getLefffService(); if (command.equals("load")) { if (lefffFilePath.length() == 0) throw new RuntimeException("Required argument: lefffFile"); final LefffLoader loader = lefffService.getLefffLoader(); File file = new File(lefffFilePath); if (startLine > 0) loader.setStartLine(startLine); if (stopLine > 0) loader.setStopLine(stopLine); loader.LoadFile(file); } else if (command.equals("serialiseBase")) { if (memoryBaseFilePath.length() == 0) throw new RuntimeException("Required argument: memoryBase"); if (posTagSetPath.length() == 0) throw new RuntimeException("Required argument: posTagSet"); if (posTagMapPath.length() == 0) throw new RuntimeException("Required argument: posTagMap"); PosTaggerServiceLocator posTaggerServiceLocator = talismaneServiceLocator.getPosTaggerServiceLocator(); PosTaggerService posTaggerService = posTaggerServiceLocator.getPosTaggerService(); File posTagSetFile = new File(posTagSetPath); PosTagSet posTagSet = posTaggerService.getPosTagSet(posTagSetFile); File posTagMapFile = new File(posTagMapPath); LefffPosTagMapper posTagMapper = lefffService.getPosTagMapper(posTagMapFile, posTagSet); Map<PosTagSet, LefffPosTagMapper> posTagMappers = new HashMap<PosTagSet, LefffPosTagMapper>(); posTagMappers.put(posTagSet, posTagMapper); LefffMemoryLoader loader = new LefffMemoryLoader(); LefffMemoryBase memoryBase = loader.loadMemoryBaseFromDatabase(lefffService, posTagMappers, categories); File memoryBaseFile = new File(memoryBaseFilePath); memoryBaseFile.delete(); loader.serializeMemoryBase(memoryBase, memoryBaseFile); } else if (command.equals("deserialiseBase")) { if (memoryBaseFilePath.length() == 0) throw new RuntimeException("Required argument: memoryBase"); LefffMemoryLoader loader = new LefffMemoryLoader(); File memoryBaseFile = new File(memoryBaseFilePath); LefffMemoryBase memoryBase = loader.deserializeMemoryBase(memoryBaseFile); String[] testWords = new String[] { "avoir" }; if (word != null) { testWords = word.split(","); } for (String testWord : testWords) { Set<PosTag> possiblePosTags = memoryBase.findPossiblePosTags(testWord); LOG.debug("##### PosTags for '" + testWord + "': " + possiblePosTags.size()); int i = 1; for (PosTag posTag : possiblePosTags) { LOG.debug("### PosTag " + (i++) + ":" + posTag); } List<? extends LexicalEntry> entriesForWord = memoryBase.getEntries(testWord); LOG.debug("##### Entries for '" + testWord + "': " + entriesForWord.size()); i = 1; for (LexicalEntry entry : entriesForWord) { LOG.debug("### Entry " + (i++) + ":" + entry.getWord()); LOG.debug("Category " + entry.getCategory()); LOG.debug("Predicate " + entry.getPredicate()); LOG.debug("Lemma " + entry.getLemma()); LOG.debug("Morphology " + entry.getMorphology()); } List<? extends LexicalEntry> entriesForLemma = memoryBase.getEntriesForLemma(testWord, ""); LOG.debug("##### Entries for '" + testWord + "' lemma: " + entriesForLemma.size()); for (LexicalEntry entry : entriesForLemma) { LOG.debug("### Entry " + entry.getWord()); LOG.debug("Category " + entry.getCategory()); LOG.debug("Predicate " + entry.getPredicate()); LOG.debug("Lemma " + entry.getLemma()); LOG.debug("Morphology " + entry.getMorphology()); for (PredicateArgument argument : entry.getPredicateArguments()) { LOG.debug("Argument: " + argument.getFunction() + ",Optional? " + argument.isOptional()); for (String realisation : argument.getRealisations()) { LOG.debug("Realisation: " + realisation); } } } } } else { System.out.println("Usage : Lefff load filepath"); } long endTime = (new Date()).getTime() - startTime; LOG.debug("Total runtime: " + ((double) endTime / 1000) + " seconds"); }
From source file:de.pniehus.odal.App.java
public static void main(String[] args) throws IOException { List<Filter> filters = new ArrayList<Filter>(); filters.add(new RegexFilter()); filters.add(new FileTypeFilter()); filters.add(new KeywordFilter()); filters.add(new BlacklistFilter()); Profile p = parseArgs(args, filters); String fileName = "log-" + new Date().toString().replace(":", "-") + ".txt"; fileName = fileName.replace(" ", "-"); File logPath = new File(p.getLogDirectory() + fileName); if (!logPath.getParentFile().isDirectory() && !logPath.getParentFile().mkdirs()) { logPath = new File(fileName); }// w w w. j a v a 2s . c o m if (logPath.getParentFile().canWrite() || logPath.getParentFile().setWritable(true)) { SimpleLoggingSetup.configureRootLogger(logPath.getAbsolutePath(), p.getLogLevel(), !p.isSilent()); } else { Logger root = Logger.getLogger(""); for (Handler h : root.getHandlers()) { // Removing default console handlers if (h instanceof ConsoleHandler) { root.removeHandler(h); } } ConsolePrintLogHandler cplh = new ConsolePrintLogHandler(); cplh.setFormatter(new ScribblerLogFormat(SimpleLoggingSetup.DEFAULT_DATE_FORMAT)); root.addHandler(cplh); System.out.println("Unable to create log: insufficient permissions!"); } Logger.getLogger("").setLevel(p.getLogLevel()); mainLogger = Logger.getLogger(App.class.getCanonicalName()); untrustedSSLSetup(); mainLogger.info("Successfully intitialized ODAL"); if (!p.isLogging()) mainLogger.setLevel(Level.OFF); if (p.isWindowsConsoleMode() && !p.isLogging()) { Logger root = Logger.getLogger(""); for (Handler h : root.getHandlers()) { if (h instanceof FileHandler) { root.removeHandler(h); // Removes FileHandler to allow console output through logging } } } OdalGui ogui = new OdalGui(p, filters); }
From source file:DateDemo.java
public static void main(String[] args) { //+//from w w w . j ava2 s. com Date dNow = new Date(); /* Simple, Java 1.0 date printing */ System.out.println("It is now " + dNow.toString()); // Use a SimpleDateFormat to print the date our way. SimpleDateFormat formatter = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); System.out.println("It is " + formatter.format(dNow)); //- }
From source file:cu.uci.gws.sdlcrawler.PdfCrawlController.java
public static void main(String[] args) throws Exception { Properties cm = PdfCrawlerConfigManager.getInstance().loadConfigFile(); long startTime = System.currentTimeMillis(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); System.out.println(dateFormat.format(date)); int numberOfCrawlers = Integer.parseInt(cm.getProperty("sdlcrawler.NumberOfCrawlers")); String pdfFolder = cm.getProperty("sdlcrawler.CrawlPdfFolder"); CrawlConfig config = new CrawlConfig(); config.setCrawlStorageFolder(cm.getProperty("sdlcrawler.CrawlStorageFolder")); config.setProxyHost(cm.getProperty("sdlcrawler.ProxyHost")); if (!"".equals(cm.getProperty("sdlcrawler.ProxyPort"))) { config.setProxyPort(Integer.parseInt(cm.getProperty("sdlcrawler.ProxyPort"))); }/*from w ww . j av a 2 s. co m*/ config.setProxyUsername(cm.getProperty("sdlcrawler.ProxyUser")); config.setProxyPassword(cm.getProperty("sdlcrawler.ProxyPass")); config.setMaxDownloadSize(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDownloadSize"))); config.setIncludeBinaryContentInCrawling( Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeBinaryContent"))); config.setFollowRedirects(Boolean.parseBoolean(cm.getProperty("sdlcrawler.Redirects"))); config.setUserAgentString(cm.getProperty("sdlcrawler.UserAgent")); config.setMaxDepthOfCrawling(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDepthCrawl"))); config.setMaxConnectionsPerHost(Integer.parseInt(cm.getProperty("sdlcrawler.MaxConnectionsPerHost"))); config.setSocketTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.SocketTimeout"))); config.setMaxOutgoingLinksToFollow(Integer.parseInt(cm.getProperty("sdlcrawler.MaxOutgoingLinks"))); config.setResumableCrawling(Boolean.parseBoolean(cm.getProperty("sdlcrawler.ResumableCrawling"))); config.setIncludeHttpsPages(Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeHttpsPages"))); config.setMaxTotalConnections(Integer.parseInt(cm.getProperty("sdlcrawler.MaxTotalConnections"))); config.setMaxPagesToFetch(Integer.parseInt(cm.getProperty("sdlcrawler.MaxPagesToFetch"))); config.setPolitenessDelay(Integer.parseInt(cm.getProperty("sdlcrawler.PolitenessDelay"))); config.setConnectionTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.ConnectionTimeout"))); System.out.println(config.toString()); Collection<BasicHeader> defaultHeaders = new HashSet<>(); defaultHeaders .add(new BasicHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")); defaultHeaders.add(new BasicHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3")); defaultHeaders.add(new BasicHeader("Accept-Language", "en-US,en,es-ES,es;q=0.8")); defaultHeaders.add(new BasicHeader("Connection", "keep-alive")); config.setDefaultHeaders(defaultHeaders); List<String> list = Files.readAllLines(Paths.get("config/" + cm.getProperty("sdlcrawler.SeedFile")), StandardCharsets.UTF_8); String[] crawlDomains = list.toArray(new String[list.size()]); PageFetcher pageFetcher = new PageFetcher(config); RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer); for (String domain : crawlDomains) { controller.addSeed(domain); } PdfCrawler.configure(crawlDomains, pdfFolder); controller.start(PdfCrawler.class, numberOfCrawlers); DateFormat dateFormat1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date1 = new Date(); System.out.println(dateFormat1.format(date1)); long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Total time:" + totalTime); }
From source file:AppendingTextPane.java
public static void main(String[] args) { try {/*from www.ja va2s .co m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Text Pane with Scrolling Append"); final AppendingTextPane atp = new AppendingTextPane(); f.getContentPane().add(new JScrollPane(atp)); f.setSize(200, 200); f.setVisible(true); // Add some text every second Timer t = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent evt) { String timeString = fmt.format(new Date()); atp.appendText(timeString + "\n"); } SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss"); }); t.start(); }