title: How to Convert python time.time() to Java
body: <p>How do I convert the following python code to Java?</p>
  
  <pre><code>import time
   str(int(time.time() * 1e6))
  </code></pre>
  
  <p>I have tried the following snippet in my Java project. </p>
  
  <pre><code>private static String runPython(String script) throws  Exception{
           File file = new File("test.py");
           if(file.exists()) {
               file.delete();
           }
           BufferedWriter out = new BufferedWriter(new FileWriter("test.py"));
           out.write(script);
           out.close();
           Process p = Runtime.getRuntime().exec("python test.py ");
           BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
           String ret = in.readLine();
           return  ret+"";
  
  }
  private static String getFromPython() {
      try {
           String prg = "import time\nprint str(int(time.time() * 1e6))\n";
  
           return  runPython(prg)+"";
       }catch(Exception e){
           e.printStackTrace();
       }
      return null;
  
  }
  
  
  public static String getFromJava() {
      String result = ((System.currentTimeMillis() / 1000) * 1e6)+"";
      return result;
  }
  
  
  public static void main(String[] args) {
      System.out.println("Python Version: "+getFromPython());
      System.out.println("Java Version: "+getFromJava());
  }
  </code></pre>
  
  <p>This are the different results am getting </p>
  
  <pre><code>run:
  Python Version: 1417515400105953
  Java Version: 1.4175154E15
  </code></pre>
  
  <p>Any one with a better approach? How is the time.time() in python different from System.currentTimeInMillies() in Java?</p>