title: I want to convert a string to date format in java 6
body: <p>My Input is like this: </p>
  
  <pre><code>20180718140032488266000Z-0600
  </code></pre>
  
  <p>and the way it should go and persist in database is like this:    </p>
  
  <pre><code>21-JUL-18 12.05.25.000000000 AM
  </code></pre>
  
  <p>Currently I have written code like this :</p>
  
  <pre><code>    public static void main(String[] argv) throws ParseException {
          // SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
          String dateInString = "20180718140032488266000Z-0600";
          Timestamp ts = formatDate(dateInString);
          System.out.println(ts);
      }
  
      private static Timestamp formatDate(String dateString) throws ParseException {
          // dateString = dateString.replaceAll("Z", "0000");
          SimpleDateFormat fmtTimestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS'Z'");
          Date dtTimestamp1 = fmtTimestamp.parse(dateString);
          Timestamp timestamp = new java.sql.Timestamp(dtTimestamp1.getTime());
          return timestamp;
      }
  </code></pre>
  
  <p>I am getting an output in this format: <code>2018-07-24 05:38:18.0</code>, my question is how can I get AM/PM also in the output. Please suggest solutions. I will be really grateful.</p>