title: How to format Java utill date for ISO m8583?
body: <p>I am using the following function that returns a formatted string date:</p>
  
  <pre><code>private static String formatDate(String format) {
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat(format);
  
      String strDate = sdf.format(date);
      return strDate;
  }
  </code></pre>
  
  <p>This function returns for example if i call it using the following format:</p>
  
  <pre><code>System.out.println(formatDate("MMYYHHMMSS"));
  </code></pre>
  
  <p>it prints: 04130904803</p>
  
  <p>When I use the above date to create an ISO message eg.</p>
  
  <pre><code>// Create ISO Message
      ISOMsg isoMsg = new ISOMsg();
      isoMsg.setPackager(packager);
      isoMsg.setMTI("0200");
              isoMsg.set(2, "100002");
      isoMsg.set(3, "201234");
      isoMsg.set(7, "04130904803");
      isoMsg.set(11, "123456");
      isoMsg.set(44, "A5DFGR");
      isoMsg.set(105, "ABCDEFGHIJ 1234567890");
  
  
      // Get and print the output result
      byte[] data = isoMsg.pack();
  
              unpackISO(new String(data));
  </code></pre>
  
  <p>I get the following error:
  =>Error: error packing field 7
  But when I remove the preceding zero of date in field 7, I works fine. What date format should i use in java to format the date? Help!</p>