List of usage examples for java.lang System currentTimeMillis
@HotSpotIntrinsicCandidate public static native long currentTimeMillis();
From source file:MainClass.java
public static void main(String args[]) { Object array = Array.newInstance(int.class, 3); int length = Array.getLength(array); Random generator = new Random(System.currentTimeMillis()); for (int i = 0; i < length; i++) { int random = generator.nextInt(); Array.setInt(array, i, random); }//from www .jav a2 s. c o m for (int i = 0; i < length; i++) { int value = Array.getInt(array, i); System.out.println("Position: " + i + ", value: " + value); } }
From source file:MainClass.java
public static void main(String[] args) { try {/*from ww w.j a v a 2 s . c o m*/ URLConnection uc = new URL("http://www.demo2s.com").openConnection(); System.out .println("Will retrieve file if it's been modified since " + new Date(uc.getIfModifiedSince())); uc.setIfModifiedSince(System.currentTimeMillis()); System.out .println("Will retrieve file if it's been modified since " + new Date(uc.getIfModifiedSince())); } catch (Exception e) { System.err.println(e); } }
From source file:Main.java
public static void main(String[] args) throws FileNotFoundException { List<Integer> arraySource = new ArrayList<>(); for (int i = 0; i < 99999; i++) { arraySource.add(i);/*w ww. j ava2s . com*/ } Integer[] myArray = new Integer[999]; myArray = arraySource.toArray(myArray); long startTime = System.currentTimeMillis(); Arrays.sort(myArray); long endTime = System.currentTimeMillis(); System.out.println("Time take in serial: " + (endTime - startTime) / 1000.0); Integer[] myArray2 = new Integer[999]; myArray2 = arraySource.toArray(myArray); startTime = System.currentTimeMillis(); Arrays.parallelSort(myArray2); endTime = System.currentTimeMillis(); System.out.println("Time take in parallel: " + (endTime - startTime) / 1000.0); }
From source file:MainClass.java
public static void main(String[] args) { try {/*from w ww. j a va 2s. c om*/ String FILE = "c:\\systemin.txt"; FileOutputStream outStr = new FileOutputStream(FILE, true); PrintStream printStream = new PrintStream(outStr); System.setErr(printStream); Timestamp now = new Timestamp(System.currentTimeMillis()); System.out.println(now.toString() + ": This is text that should go to the file"); outStr.close(); printStream.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); System.exit(-1); } catch (IOException ex) { ex.printStackTrace(); System.exit(-1); } }
From source file:TestCompilationSpeed.java
public static void main(String[] args) throws Exception { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); String fact = "function fact (n){if (n == 0)return 1; else return n*fact (n-1);};"; long time = System.currentTimeMillis(); for (int i = 0; i < MAX_ITERATIONS; i++) engine.eval(fact);/*from www. j a va 2 s . co m*/ System.out.println(System.currentTimeMillis() - time); Compilable compilable = null; if (engine instanceof Compilable) { compilable = (Compilable) engine; CompiledScript script = compilable.compile(fact); time = System.currentTimeMillis(); for (int i = 0; i < MAX_ITERATIONS; i++) script.eval(); System.out.println(System.currentTimeMillis() - time); } }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { final Date date = new Date(); final JLabel timeLabel = new JLabel(date.toString()); Timer timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { date.setTime(System.currentTimeMillis()); timeLabel.setText(date.toString()); }//from w w w .j a va 2 s . c o m }); timer.start(); JOptionPane.showMessageDialog(null, timeLabel); } }); }
From source file:componentTest.testForClient1.java
public static void main(String[] args) throws IOException, ParseException { System.out.println("**********************begin VM information****************\n"); /*Test1 read Client File which contains only one VM*/ long Time1 = System.currentTimeMillis(); LinkedList<VM> VMList = method.readClientFileAndGenerateVMList("confClient\\test3.json"); /*//from w ww . j a v a 2 s .c om for (int i=0;i<VMList.size();i++) { VMList.get(i).printInfo(); } */ //System.out.println("**********************begin policyList information****************\n"); LinkedList<ArrayList> policyList = method.readClientFileAndGenerateAbstractPolicy("confClient\\test3.json"); long Time2 = System.currentTimeMillis(); System.out.println("VM list generation duration=" + (Time2 - Time1) + "ms"); /* for (int i=0;i<policyList.size();i++) { System.out.println("*********policy List********\n"); method.printArrayList(policyList.get(i)); } */ }
From source file:edu.packt.neuralnet.som.Kohonen2DTest.java
public static void main(String[] args) { RandomNumberGenerator.seed = System.currentTimeMillis(); int numberOfInputs = 2; int neuronsGridX = 12; int neuronsGridY = 12; int numberOfPoints = 1000; double[][] rndDataSet; rndDataSet = RandomNumberGenerator.GenerateMatrixGaussian(numberOfPoints, numberOfInputs, 100.0, 1.0); //rndDataSet = RandomNumberGenerator.GenerateMatrixBetween(numberOfPoints, numberOfInputs, 100.0, 110.0); for (int i = 0; i < numberOfPoints; i++) { rndDataSet[i][0] *= Math.sin(i); rndDataSet[i][0] += RandomNumberGenerator.GenerateNext() * 50; rndDataSet[i][1] *= Math.cos(i); rndDataSet[i][1] += RandomNumberGenerator.GenerateNext() * 50; }/* w w w . ja va 2 s . c o m*/ // for (int i=0;i<numberOfPoints;i++){ // rndDataSet[i][0]=i; // rndDataSet[i][0]+=RandomNumberGenerator.GenerateNext(); // rndDataSet[i][1]=Math.cos(i/100.0); // rndDataSet[i][1]+=RandomNumberGenerator.GenerateNext()*5; // } Kohonen kn2 = new Kohonen(numberOfInputs, neuronsGridX, neuronsGridY, new GaussianInitialization(500.0, 20.0)); NeuralDataSet neuralDataSet = new NeuralDataSet(rndDataSet, 2); CompetitiveLearning complrn = new CompetitiveLearning(kn2, neuralDataSet, LearningAlgorithm.LearningMode.ONLINE); complrn.show2DData = true; complrn.printTraining = true; complrn.setLearningRate(0.5); complrn.setMaxEpochs(1000); complrn.setReferenceEpoch(300); complrn.sleep = -1; try { String[] seriesNames = { "Training Data" }; Paint[] seriesColor = { Color.WHITE }; Chart chart = new Chart("Training", rndDataSet, seriesNames, 0, seriesColor, Chart.SeriesType.DOTS); ChartFrame frame = new ChartFrame("Training", chart.scatterPlot("X", "Y")); frame.pack(); frame.setVisible(true); // //System.in.read(); complrn.setPlot2DFrame(frame); complrn.showPlot2DData(); //System.in.read(); complrn.train(); } catch (Exception ne) { } }
From source file:com.everm.httpclient.HttpClientTest.java
/** * @param args//w ww .j a va2 s . c o m */ public static void main(String[] args) { String uri = "http://samsung-cps-000.s3.amazonaws.com/PDF/-137219737027956571"; HttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(uri); HttpResponse response = null; long startTime = System.currentTimeMillis(); try { httpGet.addHeader("Date", "Mon, 18 Feb 2013 08:14:01 GMT"); httpGet.addHeader("Authorization", "AWS AKIAIULRL33KVNJCCNAQ:ac4P+U1n+ib/PkOCqyuH4lt9hK8="); // for (int i = 0; i < 100; i++) { response = client.execute(httpGet); // System.out.println(i + "___" + response.getStatusLine()); System.out.println(response.getStatusLine()); EntityUtils.consume(response.getEntity()); // } } catch (Exception e) { e.printStackTrace(); } long endTime = System.currentTimeMillis(); System.out.println("elapsed time :" + (endTime - startTime)); }
From source file:TimeTrial.java
public static void main(String[] args) { // Format Date into dd-MM-yyyy System.out.println("1) dd-MM-yyyy >>>" + DateFormatUtils.format(new Date(), "dd-MM-yyyy")); // Format Date into SMTP_DATETIME_FORMAT System.out.println("2) SMTP_DATETIME_FORMAT >>>" + DateFormatUtils.SMTP_DATETIME_FORMAT.format(new Date())); // Format Date into ISO_DATE_FORMAT System.out.println("3) ISO_DATE_FORMAT >>>" + DateFormatUtils.ISO_DATE_FORMAT.format(new Date())); // Format milliseconds in long System.out.println(//from w w w . ja v a 2 s. c o m "4) MMM dd yy HH:mm >>>" + DateFormatUtils.format(System.currentTimeMillis(), "MMM dd yy HH:mm")); // Format milliseconds in long using UTC timezone System.out.println( "5) MM/dd/yy HH:mm >>>" + DateFormatUtils.formatUTC(System.currentTimeMillis(), "MM/dd/yy HH:mm")); }