title: How to get the current time in YYYY-MM-DD HH:MI:Sec.Millisecond format in Java?
body: <p>The code below gives me the current time. But it does not tell anything about milliseconds.</p>
  <pre><code>public static String getCurrentTimeStamp() {
      SimpleDateFormat sdfDate = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;);//dd/MM/yyyy
      Date now = new Date();
      String strDate = sdfDate.format(now);
      return strDate;
  }
  </code></pre>
  <p>I have a date in the format <code>YYYY-MM-DD HH:MM:SS</code> (<code>2009-09-22 16:47:08</code>).</p>
  <p>But I want to retrieve the current time in the format <code>YYYY-MM-DD HH:MM:SS.MS</code> (<code>2009-09-22 16:47:08.128</code>, where <code>128</code> are the milliseconds).</p>
  <p><code>SimpleTextFormat</code> will work fine. Here the lowest unit of time is second, but how do I get millisecond as well?</p>