This is a generic java class that can be used to change the format of the date, monthand year. Also, hours, minutes and seconds.
This class I use in Oracle Service Bus (OSB) to change the conversion date, for example, from the target system date format obtained ”yyyyMMddHHmmss” and will be changed to ”dd / MM / yyyy HH: mm: ss”.
package com.util;
import java.text.SimpleDateFormat;
public class DateFormat {
public static String changeFormatDate(String strDate, String frmFormat, String toFormat) {
String date = "";
if (frmFormat.equalsIgnoreCase("ddMMyy") && strDate.length() == 5) {
strDate = "0" + strDate;
}
SimpleDateFormat df1 = new SimpleDateFormat(frmFormat);
SimpleDateFormat df2 = new SimpleDateFormat(toFormat);
try {
date = df2.format(df1.parse(strDate));
} catch (Exception e) {
}
return date;
}
public static void main(String[] srt) {
try {
System.out.println(changeFormatDate("20100118180740", "yyyyMMddHHmmss", "dd/MM/yyyy-HHmmss"));
System.out.println(changeFormatDate("010211", "ddmmyy", "dd/mm/yyyy"));
} catch (Exception e) {}
}
}
Then create a java class above. JAR, and imported in OSB.
Call the class through the ”Java callout”.
*This class was made by DPS Corp.
