List of usage examples for java.text SimpleDateFormat SimpleDateFormat
public SimpleDateFormat(String pattern)
SimpleDateFormat
using the given pattern and the default date format symbols for the default java.util.Locale.Category#FORMAT FORMAT locale. From source file:eu.optimis.infrastructureproviderriskassessmenttool.core.riskmonitoring.MonClientCommandline.java
public static void main(String[] args) { //PropertyConfigurator.configure(ConfigManager.getConfigFilePath(ConfigManager.LOG4J_CONFIG_FILE)); log.info("IPRA: Test Monitoring Client..."); PropertiesConfiguration configOptimis = ConfigManager .getPropertiesConfiguration(ConfigManager.OPTIMIS_CONFIG_FILE); // Test Monitoring Access getClient mclient = new getClient(configOptimis.getString("optimis-ipvm"), Integer.parseInt(configOptimis.getString("monitoringport")), configOptimis.getString("monitoringpath")); /* /*w w w . j a v a 2 s . co m*/ CloudOptimizerRESTClient CoClient = new CloudOptimizerRESTClient(rb.getString("config.coservicehost"), Integer.parseInt(rb.getString("config.coserviceport")), "CloudOptimizer"); System.out.println(CoClient.getNodesId().get(0)); System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); System.out.println(CoClient.getPhysicalResource("optimis1")); System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); System.out.println(CoClient.getVMsIdsOfService("DemoApp")); System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); */ MonitoringResourceDatasets mrd = null; /* mrd = mclient.getReportForAllPhysical(); MonPrinter(mrd); mrd = mclient.getReportForAllVirtual(); MonPrinter(mrd); */ //mrd = mclient.getLatestReportForPhysical("optimis1"); //mrd = mclient.getLatestReportForMetricName("free_memory","physical"); //mrd = mclient.getReportForService("DemoApp"); DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date start = null; try { start = df.parse("01/01/2010"); } catch (ParseException e) { e.printStackTrace(); } Date end = new Date(); //mrd = mclient.getReportForPartMetricName("status", "physical", start, end); //MonPrinter(mrd); mrd = mclient.getReportForPartMetricName("vm_state", "virtual", start, end); MonPrinter(mrd); }
From source file:org.jfree.chart.demo.ImageMapDemo3.java
/** * Starting point for the demo.// www .java 2 s. c o m * * @param args ignored. * * @throws ParseException if there is a problem parsing dates. */ public static void main(final String[] args) throws ParseException { // Create a sample dataset final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); final XYSeries dataSeries = new XYSeries("Curve data"); final ArrayList toolTips = new ArrayList(); dataSeries.add(sdf.parse("01-Jul-2002").getTime(), 5.22); toolTips.add("1D - 5.22"); dataSeries.add(sdf.parse("02-Jul-2002").getTime(), 5.18); toolTips.add("2D - 5.18"); dataSeries.add(sdf.parse("03-Jul-2002").getTime(), 5.23); toolTips.add("3D - 5.23"); dataSeries.add(sdf.parse("04-Jul-2002").getTime(), 5.15); toolTips.add("4D - 5.15"); dataSeries.add(sdf.parse("05-Jul-2002").getTime(), 5.22); toolTips.add("5D - 5.22"); dataSeries.add(sdf.parse("06-Jul-2002").getTime(), 5.25); toolTips.add("6D - 5.25"); dataSeries.add(sdf.parse("07-Jul-2002").getTime(), 5.31); toolTips.add("7D - 5.31"); dataSeries.add(sdf.parse("08-Jul-2002").getTime(), 5.36); toolTips.add("8D - 5.36"); final XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); final CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator(); ttg.addToolTipSeries(toolTips); // Create the chart final StandardXYURLGenerator urlg = new StandardXYURLGenerator("xy_details.jsp"); final ValueAxis timeAxis = new DateAxis(""); final NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, null); final StandardXYItemRenderer sxyir = new StandardXYItemRenderer( StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, urlg); sxyir.setShapesFilled(true); plot.setRenderer(sxyir); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("xychart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("xychart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"xychart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } return; }
From source file:GridFDock.GridFDockRunner.java
public static void main(String[] args) { SimpleDateFormat sdf = null;// w w w . j ava2 s .co m String executeTime; try { System.out.println("*********** Work Started **********"); System.out.println("###################################################################" + "\n" + "# If you used MolGridCal in your work, please cite: #" + "\n" + "# #" + "\n" + "# Qifeng Bai, PLoS One. 2014 Sep 17;9(9):e107837. #" + "\n" + "# Download site: https://github.com/MolGridCal/MolGridCal #" + "\n" + "# E-mail (molaical@yeah.net) #" + "\n" + "# Blog website (http://molgridcal.blog.163.com). #" + "\n" + "###################################################################"); // Create the client. jppfClient = new JPPFClient(); // create a runner instance. GridFDockRunner runner = new GridFDockRunner(); // Create a job sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); executeTime = sdf.format(new java.util.Date()); System.out.println("Executed time is on: " + executeTime); runner.executeBlockingJob(jppfClient); // JPPFJob job = runner.buildJob(); // execute a blocking job // runner.executeBlockingJob(job); } catch (Exception e) { System.out.println("get bad results******!"); e.printStackTrace(); } finally { if (jppfClient != null) jppfClient.close(); } executeTime = sdf.format(new java.util.Date()); System.out.println("The work finished time is on: " + executeTime); System.gc(); }
From source file:com.bialx.ebics.FDL.java
public static void main(String[] args) throws Exception { String userId = ""; Boolean isTest = false;//from w w w . jav a 2s. co m Date startDate = null; Date endDate = null; SimpleDateFormat dtFormat = new SimpleDateFormat("yyyyMMdd"); CommandLineParser parser = new DefaultParser(); BialxOptions options = new BialxOptions(); // Parse the program arguments CommandLine commandLine = parser.parse(options, args); // optional values if (commandLine.hasOption('s')) { startDate = dtFormat.parse(commandLine.getOptionValue('s')); } if (commandLine.hasOption('e')) { endDate = dtFormat.parse(commandLine.getOptionValue('e')); } if (commandLine.hasOption('t')) { isTest = true; } FDL fdl; PasswordCallback pwdHandler; Product product; fdl = new FDL(); pwdHandler = new UserPasswordHandler(userId, CERT_PASSWORD); product = new Product("Bial-x EBICS FDL", Locale.FRANCE, null); if (commandLine.hasOption(BialxOptions.OPTION_CREATION) && !commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) { if (options.checkCreationOptions(commandLine)) { CreationOptions co = options.loadCreationOptions(commandLine); fdl.configuration.getLogger().info(String.format("Banque : %s", co.getBankName())); fdl.configuration.getLogger().info(String.format("Host : %s", co.getHostId())); fdl.configuration.getLogger().info(String.format("URL : %s", co.getBankUrl())); fdl.configuration.getLogger().info(String.format("Partner : %s", co.getPartnerId())); fdl.configuration.getLogger().info(String.format("User : %s", co.getUserId())); User user = fdl.createUser(co.getUserId(), co.getHostId(), co.getPartnerId(), co.getBankName(), co.getBankUrl(), pwdHandler); fdl.sendHPBRequest(user, product); } else { fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande."); System.exit(0); } } if (!commandLine.hasOption(BialxOptions.OPTION_CREATION) && commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) { if (options.checkDownloadOptions(commandLine)) { DownloadOptions dop = options.loadDownloadOptions(commandLine); fdl.configuration.getLogger().info(String.format("Banque : %s", dop.getHostId())); fdl.configuration.getLogger().info(String.format("Host : %s", dop.getHostId())); fdl.configuration.getLogger().info(String.format("Partner : %s", dop.getPartnerId())); fdl.configuration.getLogger().info(String.format("User : %s", dop.getUserId())); fdl.configuration.getLogger().info(String.format("Format : %s", dop.getFormat())); fdl.configuration.getLogger().info(String.format("Destination : %s", dop.getDestination())); if (startDate != null) { fdl.configuration.getLogger() .info(String.format("Date dbut : %s", dtFormat.format(startDate))); } if (endDate != null) { fdl.configuration.getLogger().info(String.format("Date fin : %s", dtFormat.format(endDate))); } fdl.loadUser(dop.getHostId(), dop.getPartnerId(), dop.getUserId(), pwdHandler); fdl.fetchFile(dop.getDestination(), dop.getUserId(), dop.getFormat(), product, OrderType.FDL, isTest, startDate, endDate); } else { fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande."); System.exit(0); } } if (commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD) && commandLine.hasOption(BialxOptions.OPTION_CREATION)) { fdl.configuration.getLogger().error("Impossible d'avoir les options C et D dans la mme commande."); System.exit(0); } fdl.quit(); }
From source file:my.yelp.populate.java
public static void main(String[] args) throws FileNotFoundException, ParseException, IOException, java.text.ParseException { try {/*from ww w . j ava2s .co m*/ DbConnection A1 = new DbConnection(); Connection con = A1.getConnection(); JSONParser jsonParser; jsonParser = new JSONParser(); Object obj1 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_user.json")); Object obj2 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_business.json")); Object obj3 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_review.json")); Object obj4 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_checkin.json")); JSONArray jsonArray1; jsonArray1 = (JSONArray) obj1; JSONArray jsonArray2; jsonArray2 = (JSONArray) obj2; JSONArray jsonArray3; jsonArray3 = (JSONArray) obj3; JSONArray jsonArray4; jsonArray4 = (JSONArray) obj4; // yelp_user String yelping_since, name1, user_id, type1; Long review_count1, fans; Double average_stars; Statement stmt; stmt = con.createStatement(); stmt.executeUpdate("Delete from N_User"); for (int i = 0; i < (jsonArray1.size()); i++) { JSONObject jsonObject = (JSONObject) jsonArray1.get(i); yelping_since = (String) jsonObject.get("yelping_since") + "-01"; JSONArray friends = (JSONArray) jsonObject.get("friends"); int friends_size = friends.size(); review_count1 = (Long) jsonObject.get("review_count"); name1 = (String) jsonObject.get("name"); user_id = (String) jsonObject.get("user_id"); fans = (Long) jsonObject.get("fans"); average_stars = (Double) jsonObject.get("average_stars"); type1 = (String) jsonObject.get("type"); try (PreparedStatement pstmt1 = con.prepareStatement( "Insert INTO N_User(yelping_since,friends_size,review_count,name,user_id,fans,average_stars,type) VALUES(?,?,?,?,?,?,?,?)")) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date myDate = format.parse(yelping_since); pstmt1.setDate(1, new java.sql.Date(myDate.getTime())); pstmt1.setInt(2, friends_size); pstmt1.setLong(3, review_count1); pstmt1.setString(4, name1); pstmt1.setString(5, user_id); pstmt1.setLong(6, fans); pstmt1.setDouble(7, average_stars); pstmt1.setString(8, type1); pstmt1.executeUpdate(); } catch (java.text.ParseException ex) { Logger.getLogger(populate.class.getName()).log(Level.SEVERE, null, ex); } } //yelp_business String business_id, address, city, state, name, type_business; Double stars; for (int i = 0; i < jsonArray2.size(); i++) { JSONObject jsonObject = (JSONObject) jsonArray2.get(i); business_id = (String) jsonObject.get("business_id"); address = (String) jsonObject.get("full_address"); city = (String) jsonObject.get("city"); state = (String) jsonObject.get("state"); name = (String) jsonObject.get("name"); stars = (Double) jsonObject.get("stars"); type_business = (String) jsonObject.get("type"); try (PreparedStatement pstmt2 = con.prepareStatement( "Insert INTO N_Business(business_id,address,city,state,name,stars,type_business) VALUES(?,?,?,?,?,?,?)")) { pstmt2.setString(1, business_id); pstmt2.setString(2, address); pstmt2.setString(3, city); pstmt2.setString(4, state); pstmt2.setString(5, name); pstmt2.setDouble(6, stars); pstmt2.setString(7, type_business); pstmt2.executeUpdate(); pstmt2.close(); } } //Category Table String[] categories = { "Active Life", "Arts & Entertainment", "Automotive", "Car Rental", "Cafes", "Beauty & Spas", "Convenience Stores", "Dentists", "Doctors", "Drugstores", "Department Stores", "Education", "Event Planning & Services", "Flowers & Gifts", "Food", "Health & Medical", "Home Services", "Home & Garden", "Hospitals", "Hotels & travel", "Hardware stores", "Grocery", "Medical Centers", "Nurseries & Gardening", "Nightlife", "Restaurants", "Shopping", "Transportation" }; JSONArray category; String[] individual_category = new String[100]; int count = 0, flag = 0, m = 0, n = 0; String[] business_category = new String[50]; String[] subcategory = new String[50]; for (int i = 0; i < jsonArray2.size(); i++) { JSONObject jsonObject3 = (JSONObject) jsonArray2.get(i); String business_id2 = (String) jsonObject3.get("business_id"); category = (JSONArray) jsonObject3.get("categories"); for (int j = 0; j < category.size(); j++) { individual_category[j] = (String) category.get(j); count = count + 1; } for (int k = 0; k < count; k++) { for (String categorie : categories) { if (individual_category[k].equals(categorie)) { flag = 1; break; } } if (flag == 1) { business_category[m] = individual_category[k]; m = m + 1; flag = 0; } else { subcategory[n] = individual_category[k]; n = n + 1; } } for (int p = 0; p < m; p++) { for (int q = 0; q < n; q++) { try (PreparedStatement pstmt3 = con.prepareStatement( "INSERT INTO N_Category(business_id,category,subcategory) VALUES(?,?,?)")) { pstmt3.setString(1, business_id2); pstmt3.setString(2, business_category[p]); pstmt3.setString(3, subcategory[q]); pstmt3.executeUpdate(); } } } count = 0; m = 0; n = 0; } //yelp_review String user_id3, review_id, type3, business_id3, text, text1, review_date; Long stars3; int votes = 0; Integer no_votes; JSONObject votes_info; Set<String> keys; for (int i = 0; i < jsonArray3.size(); i++) { JSONObject jsonObject = (JSONObject) jsonArray3.get(i); votes_info = (JSONObject) jsonObject.get("votes"); keys = votes_info.keySet(); for (String r_key : keys) { votes = (int) (votes + (Long) votes_info.get(r_key)); } no_votes = toIntExact(votes); user_id3 = (String) jsonObject.get("user_id"); review_id = (String) jsonObject.get("review_id"); business_id3 = (String) jsonObject.get("business_id"); review_date = (String) jsonObject.get("date"); text1 = (String) jsonObject.get("text"); text = text1.substring(0, Math.min(1000, text1.length())); stars3 = (Long) jsonObject.get("stars"); type3 = (String) jsonObject.get("type"); try (PreparedStatement pstmt4 = con.prepareStatement( "Insert INTO N_Review(no_votes,user_id,review_id,business_id,review_date,text,stars,type) VALUES(?,?,?,?,?,?,?,?)")) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date myDate = format.parse(review_date); pstmt4.setInt(1, no_votes); pstmt4.setString(2, user_id3); pstmt4.setString(3, review_id); pstmt4.setString(4, business_id3); pstmt4.setDate(5, new java.sql.Date(myDate.getTime())); pstmt4.setString(6, text); pstmt4.setLong(7, stars3); pstmt4.setString(8, type3); pstmt4.executeUpdate(); pstmt4.close(); } } //Checkin_Info JSONObject checkin_info; String business_id4; Long check_in_count; Set<String> keys1; String[] timing = new String[10]; int n1 = 0, time, hour; //Inserting into checkin_info for (int i = 0; i < jsonArray4.size(); i++) { JSONObject jsonObject4 = (JSONObject) jsonArray4.get(i); checkin_info = (JSONObject) jsonObject4.get("checkin_info"); business_id4 = (String) jsonObject4.get("business_id"); keys1 = checkin_info.keySet(); for (String key : keys1) { check_in_count = (Long) checkin_info.get(key); for (String x : key.split("-")) { timing[n1] = x; n1 = n1 + 1; } n1 = 0; hour = Integer.parseInt(timing[0]); time = Integer.parseInt(timing[1]); try (PreparedStatement pstmt5 = con.prepareStatement( "INSERT INTO check_info(business_id,hour,day,check_in_count)VALUES(?,?,?,?)")) { pstmt5.setString(1, business_id4); pstmt5.setInt(2, hour); pstmt5.setInt(3, time); pstmt5.setLong(4, check_in_count); pstmt5.executeUpdate(); } } } con.close(); } catch (SQLException ex) { Logger.getLogger(populate.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:info.usbo.skypetwitter.Run.java
public static void main(String[] args) { System.out.println("Working Directory = " + System.getProperty("user.dir")); Properties props;// w w w .j av a 2 s . co m props = (Properties) System.getProperties().clone(); //loadProperties(props, "D:\\Data\\Java\\classpath\\twitter.props"); work_dir = System.getProperty("user.dir"); loadProperties(props, work_dir + "\\twitter.props"); twitter_user_id = props.getProperty("twitter.user"); twitter_timeout = Integer.parseInt(props.getProperty("twitter.timeout")); System.out.println("Twitter user: " + twitter_user_id); System.out.println("Twitter timeout: " + twitter_timeout); if ("".equals(twitter_user_id)) { return; } if (load_file() == 0) { System.out.println("File not found"); return; } while (true) { bChanged = 0; /* create_id(); Chat ch = Chat.getInstance(chat_group_id); ch.send("!"); */ SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm"); System.out.println("Looking at " + sdf.format(Calendar.getInstance().getTime())); Chat ch = Chat.getInstance(chat_group_id); Twitter twitter = new TwitterFactory().getInstance(); try { List<Status> statuses; statuses = twitter.getUserTimeline(twitter_user_id); //System.out.println("Showing @" + twitter_user_id + "'s user timeline."); String sText; for (Status status : statuses) { //System.out.println(status.getId()); Date d = status.getCreatedAt(); // ? Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.HOUR_OF_DAY, 7); d = cal.getTime(); sText = "@" + status.getUser().getScreenName() + " " + sdf.format(d) + " ( https://twitter.com/" + twitter_user_id + "/status/" + status.getId() + " ): \r\n" + status.getText() + "\r\n***"; for (URLEntity e : status.getURLEntities()) { sText = sText.replaceAll(e.getURL(), e.getExpandedURL()); } for (MediaEntity e : status.getMediaEntities()) { sText = sText.replaceAll(e.getURL(), e.getMediaURL()); } if (twitter_ids.indexOf(status.getId()) == -1) { System.out.println(sText); ch.send(sText); twitter_ids.add(status.getId()); bChanged = 1; } } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); //System.exit(-1); } catch (SkypeException ex) { ex.printStackTrace(); System.out.println("Failed to send message: " + ex.getMessage()); } // VK try { vk(); for (VK v : vk) { if (vk_ids.indexOf(v.getId()) == -1) { Date d = v.getDate(); // ? Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.HOUR_OF_DAY, 7); d = cal.getTime(); String sText = "@Depersonilized (VK) " + sdf.format(d) + " ( http://vk.com/Depersonilized?w=wall-0_" + v.getId() + " ): \r\n" + v.getText(); if (!"".equals(v.getAttachment())) { sText += "\r\n" + v.getAttachment(); } sText += "\r\n***"; System.out.println(sText); ch.send(sText); vk_ids.add(v.getId()); bChanged = 1; } } } catch (ParseException e) { e.printStackTrace(); System.out.println("Failed to get vk: " + e.getMessage()); //System.exit(-1); } catch (SkypeException ex) { ex.printStackTrace(); System.out.println("Failed to send message: " + ex.getMessage()); } if (bChanged == 1) { save_file(); } try { Thread.sleep(1000 * 60 * twitter_timeout); } catch (InterruptedException ex) { ex.printStackTrace(); System.out.println("Failed to sleep: " + ex.getMessage()); } } }
From source file:net.anthonypoon.ngram.rollingregression.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("f", "format", true, "Format"); options.addOption("u", "upbound", true, "Year up bound"); options.addOption("l", "lowbound", true, "Year low bound"); options.addOption("r", "range", true, "Range"); options.addOption("T", "threshold", true, "Threshold - min count for regression"); options.addOption("p", "positive-only", false, "Write positive slope only"); // default faluse CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); Configuration conf = new Configuration(); if (cmd.hasOption("range")) { conf.set("range", cmd.getOptionValue("range")); }//w w w . j a v a2s. c o m if (cmd.hasOption("upbound")) { conf.set("upbound", cmd.getOptionValue("upbound")); } else { conf.set("upbound", "9999"); } if (cmd.hasOption("lowbound")) { conf.set("lowbound", cmd.getOptionValue("lowbound")); } else { conf.set("lowbound", "0"); } if (cmd.hasOption("threshold")) { conf.set("threshold", cmd.getOptionValue("threshold")); } if (cmd.hasOption("positive-only")) { conf.set("positive-only", "true"); } Job job = Job.getInstance(conf); /** if (cmd.hasOption("format")) { switch (cmd.getOptionValue("format")) { case "compressed": job.setInputFormatClass(SequenceFileAsTextInputFormat.class); break; case "text": job.setInputFormatClass(KeyValueTextInputFormat.class); break; } }**/ job.setJarByClass(Main.class); switch (cmd.getOptionValue("action")) { case "get-regression": job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); for (String inputPath : cmd.getOptionValue("input").split(",")) { MultipleInputs.addInputPath(job, new Path(inputPath), KeyValueTextInputFormat.class, RollingRegressionMapper.class); } job.setReducerClass(RollingRegressionReducer.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); /** double[] nazismBaseLine = {3, 12, 12, 18, 233, 239, 386, 333, 593, 1244, 1925, 3013, 3120, 3215, 3002, 3355, 2130, 1828, 1406, 1751, 1433, 1033, 881, 1330, 1029, 760, 1288, 1013, 1014}; InputStream inStream = Main.class.getResourceAsStream("/1g-matrix.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(inStream)); String line = ""; Map<String, Double> result = new HashMap(); while ((line = br.readLine()) != null) { String[] strArray = line.split("\t"); double[] compareArray = new double[nazismBaseLine.length]; for (int i = 0; i < nazismBaseLine.length; i ++) { compareArray[i] = Double.valueOf(strArray[i + 24]); } result.put(strArray[0], new PearsonsCorrelation().correlation(nazismBaseLine, compareArray)); } List<Map.Entry<String, Double>> toBeSorted = new ArrayList(); for (Map.Entry pair : result.entrySet()) { toBeSorted.add(pair); } Collections.sort(toBeSorted, new Comparator<Map.Entry<String, Double>>(){ @Override public int compare(Map.Entry<String, Double> o1, Map.Entry<String, Double> o2) { return o2.getValue().compareTo(o1.getValue()); } }); for (Map.Entry<String, Double> pair : toBeSorted) { if (!Double.isNaN(pair.getValue())) { System.out.println(pair.getKey() + "\t" + pair.getValue()); } }**/ }
From source file:com.webkruscht.wmt.DownloadFiles.java
/** * @param args/*from w w w. j av a 2s. c om*/ * @throws Exception */ public static void main(String[] args) throws Exception { WebmasterTools wmt; String filename; Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String today = sdf.format(date); getProperties(); Options options = getOptions(args); try { wmt = new WebmasterTools(username, password); for (SitesEntry entry : wmt.getUserSites()) { // only process verified sites if (entry.getVerified()) { // get download paths for site JSONObject data = wmt.getDownloadList(entry); if (data != null) { for (String prop : props) { String path = (String) data.get("TOP_QUERIES"); path += "&prop=" + prop; URL url = new URL(entry.getTitle().getPlainText()); if (options.getStartdate() != null) { path += "&db=" + options.getStartdate(); path += "&de=" + options.getEnddate(); filename = String.format("%s-%s-%s-%s-%s.csv", url.getHost(), options.getStartdate(), options.getEnddate(), prop, "TopQueries"); } else { filename = String.format("%s-%s-%s-%s.csv", url.getHost(), today, prop, "TopQueries"); } OutputStreamWriter out = new OutputStreamWriter( new FileOutputStream(filePath + filename), "UTF-8"); wmt.downloadData(path, out); out.close(); } String path = (String) data.get("TOP_PAGES"); URL url = new URL(entry.getTitle().getPlainText()); filename = String.format("%s-%s-%s.csv", url.getHost(), today, "TopQueries"); OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(filePath + filename), "UTF-8"); wmt.downloadData(path, out); out.close(); } } } } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:Tester2.java
public static void main(String[] args) { try {//from ww w . ja v a 2 s .co m String line7 = "1 25544U 98067A 16003.88353887 .00008341 00000-0 12778-3 0 9994"; String line8 = "2 25544 51.6424 162.4509 0008302 358.1918 164.3460 15.55244436979265"; double latitude = 36.211389; double longitude = -81.668611; double altitude = 1016; // configure Orekit AutoconfigurationCustom.configureOrekit(); //SUNLocation CelestialBody testSun = CelestialBodyFactory.getSun(); CelestialBody testEarth = CelestialBodyFactory.getEarth(); // Get UTC time SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); String[] utcTime = sdf.format(new Date()).split(","); // Gets times and date double futureDayProp = 3; // duration in 24-hour day //AbsoluteDate currentDate = new AbsoluteDate(2016, 1, 1, 23, 50, 0.000, TimeScalesFactory.getUTC()); AbsoluteDate currentDate = new AbsoluteDate(Integer.parseInt(utcTime[0]), Integer.parseInt(utcTime[1]), Integer.parseInt(utcTime[2]), Integer.parseInt(utcTime[3]), Integer.parseInt(utcTime[4]), Integer.parseInt(utcTime[5]), TimeScalesFactory.getUTC()); Tester2 awesome = new Tester2(line7, line8, testSun, testEarth, latitude, longitude, altitude, currentDate.shiftedBy(futureDayProp * 24 * 3600));//targetDate.shiftedBy(3*24*3600)); awesome.QuickCheck(); System.out.println("done"); // Propagate from the initial date to the first raising or for the fixed duration ////////////////SpacecraftState finalState = TLEProp.propagate(targetDate); ///////////////////System.out.println(" Final state : " + finalState.getDate().durationFrom(targetDate)); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:ie.aib.nbp.zosresttest.RunTest.java
/** * @param args the command line arguments *///from w w w . j a va 2s. com public static void main(String[] args) { PrintStream printer = null; if (args.length < 2) { System.out.println("***************************************************************************"); System.out.println("* Z/OS REST SERVICES PERFORMANCE TESTER *"); System.out.println("* *"); System.out.println("* At least 2 run parameters are required: *"); System.out.println("* 1 username: your mainframe username *"); System.out.println("* 2 password: your mainframe passeord *"); System.out.println("* 3 runtime behaviour switch: 1 - active, everything else - inactive *"); System.out.println("* this parameter is optional and causes the app to run the test or not *"); System.out.println("* lack of it assings default value: 0 *"); System.out.println("* which triggers the service discovery feature *"); System.out.println("* and displays all currently available services *"); System.out.println("* 4 output type: *"); System.out.println("* F - output to file (then fifth parameter hold the file location) *"); System.out.println("* Everything else (including no parameter at all) outputs to console *"); System.out.println("***************************************************************************"); return; } readConfig(CONFIG_FILE_PATH); String username = args[0]; String password = args[1]; String runPerformanceTest; try { runPerformanceTest = args[2]; } catch (ArrayIndexOutOfBoundsException ex) { runPerformanceTest = "0"; } String outputType; String outputFileLocation; try { outputType = args[3]; // F saves to file, everything else output to console } catch (ArrayIndexOutOfBoundsException ex) { outputType = "C"; } if (outputType.equalsIgnoreCase("F")) { // write to file String outputFile; try { outputFile = args[4]; // if prev param is F then this one may contain the file name (default name instead) } catch (ArrayIndexOutOfBoundsException ex) { SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy-HHmmssZ"); outputFile = "ZosPerformanceTest".concat("-".concat(sdf.format(new Date()))).concat(".txt"); } try { String filePath = config.getProperty("OUT_FILE_PATH").concat(outputFile); printer = new PrintStream(new FileOutputStream(filePath, true)); } catch (FileNotFoundException ex) { Logger.getLogger(RunTest.class.getName()).log(Level.SEVERE, null, ex); } } else { // othewise write to java console printer = new PrintStream(System.out); } if (runPerformanceTest.equals("1")) runPerformanceTest(username, password, printer, true, false); else runServiceDiscovery(username, password, printer); }