I am using the following function that returns a formatted string date:
private static String formatDate(String format) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(format);
String strDate = sdf.format(date);
return strDate;
}
This function returns for example if i call it using the following format:
System.out.println(formatDate("MMYYHHMMSS"));
it prints: 04130904803
When I use the above date to create an ISO message eg.
// 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));
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!
You use ISODate.getDateTime(Date d)
or ISODate.getDateTime(Date, TimeZone)
.