title: How to generate date with milliseconds
body: <p>I tested this code: </p>
  
  <pre><code>java.util.Date d=new java.util.Date();
  System.out.println("date="+d);
  </code></pre>
  
  <p>The output is: </p>
  
  <blockquote>
    <p>Sat May 09 02:48:42 CDT 2015</p>
  </blockquote>
  
  <p>It has no milliseconds...</p>
  
  <p>p.s lets say if to use <code>Date</code> for <code>ConcurrentLinkedHashMap&lt;Date,String&gt;</code> (<a href="https://code.google.com/p/concurrentlinkedhashmap/wiki/" rel="nofollow">wiki link</a>) I can see the minimum date value is second :( </p>
  
  <p><strong>EDIT</strong> : </p>
  
  <pre><code>public class HashMapTest0 {
  
      private ConcurrentMap&lt;Date,Date&gt; values=new ConcurrentLinkedHashMap.Builder&lt;Date, Date&gt;()
              .maximumWeightedCapacity(1000)
              .build();
  
      public static void main(String [] args){new HashMapTest0();}
  
      HashMapTest0(){
  
  
          for(int i=0; i&lt;10; i++){
  
              Date d=new Date();            
              values.put(d, d);
  
              try {
                  Thread.sleep(10);
              } catch (InterruptedException ex) {
                  ex.printStackTrace();
              }
          }
  
          for(Date d:values.values()){
              String s=new SimpleDateFormat("dd-MM-yyyy:HH:mm:ss.sss").format(d)
                              .replaceAll("-", "_")
                              .replaceAll(":", "_");
              System.out.println(s);
          }
  
      }
  
  }
  </code></pre>
  
  <p>the output maybe something like this : </p>
  
  <pre><code>09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  09_05_2015_04_07_10.010
  </code></pre>
  
  <p>So my question is how to generate date with real time milliseconds, or is there is a more optimal way? </p>