title: Convert date with nanoseconds in java
body: <p>I have a date in this format <strong>"2017-05-17 00:31:16.227"</strong>, I need to convert it to <strong>"17-MAY-17 12.31.16.227000000 AM"</strong>.</p>
  
  <pre><code>String convertTimestamp(Timestamp date) {
  
      String newstring = null;
      try {
          SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSSSSSSS");
          java.util.Date date1 = dateFormat.parse(date.toString());
          DateFormat sdf = new SimpleDateFormat("dd-MMM-yy hh.mm.ss.SSSSSSSSS aa");
          newstring = sdf.format(date1);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      System.out.println("new string" + newstring);
  
      return newstring;
  }
  </code></pre>
  
  <p>but I am getting the value like this **"17-MAY-17 12.31.16.000000227 AM"</p>