title: Current Date & Time in Java
body: <p>I want the current date and time in the following format :</p>
  
  <p>Date  :YYYYMMDD</p>
  
  <p>Time : HHMMSS</p>
  
  <p>I tried the following </p>
  
  <pre><code>DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
     //get current date time with Date()
     Date date = new Date();
     System.out.println(dateFormat.format(date));
  
     //get current date time with Calendar()
     Calendar cal = Calendar.getInstance();
     System.out.println(new Date().getTime());
  </code></pre>
  
  <p>By this I am getting the desired date output but the time is coming in this way 1341837848290.</p>
  
  <p>The expected is HHMMSS.</p>