//
you're reading...
Oracle Service Bus (OSB)

Conversion Date in Oracle Service Bus [OSB] use generic java class

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. :)

Advertisement

Discussion

One Response to “Conversion Date in Oracle Service Bus [OSB] use generic java class”

  1. Nice,, helpful :)
    Thx u

    Posted by Jix | April 25, 2011, 5:32 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.