Changing Date Format in OAF(java coding)


 You can change the date format using SimpleDateFormat class

1. Tell the old string format

2. Convert to new String Format

We use two methods to change parse and format. The code is given below

SimpleDateFormat sdf = new SimpleDateFormat(“dd-MMM-yyyy”);   //old format

SimpleDateFormat sdf1 = new SimpleDateFormat(“dd-MM-yyyy”);   //new format

OAMessageStyledTextBean ti=(OAMessageStyledTextBean)webBean.findChildRecursive(“DateFieldItem1”);

String dt=(ti.getValue(pageContext)).toString();   //Getting the date

System.out.println(“ti——–=============————-============———>”+dt);

try{

System.out.println(“sdf.parse(dt)====>”+sdf.parse(dt));

java.util.Date aj =sdf.parse(dt);                //Changing the String to Date with format

this.dtfor=sdf1.format(aj);                      //Conversion takes place

System.out.println(“dtfor”+dtfor);

}

catch(Exception e)                                         //parse method throws Parse Exception

{

System.out.println(“Exception Occured”+e);

}

System.out.println(“Second test for dtfor”+dt+dtfor);

this.dtfor=dtfor;

 

 

About pacesettergraam

A good and realistic person

Posted on December 17, 2013, in OAF, Oracle and tagged , , . Bookmark the permalink. Leave a comment.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: