In OAF if we create an attribute with DATE type then the value retained will be in the format of yyyy-MM-dd hh:mm:ss.S
Ex: 2019-05-25 00:00:00.0
Code to handle the Date Conversion:
import java.text.SimpleDateFormat;
String convStr1=null;
OAMessageDateFieldBean par1=(OAMessageDateFieldBean )webBean.findIndexedChildRecursive("crTargetFrom");
Timestamp TargetFrom = (Timestamp)par1.getValue(pageContext);
System.out.println("Target From :"+TargetFrom);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
SimpleDateFormat formatDate = new SimpleDateFormat("dd-MMM-yyyy");
try
{
java.util.Date dateStr1 = format.parse(TargetFrom.toString());
convStr1 = formatDate.format(dateStr1);
System.out.println("String date Converted : "+convStr1);
}
catch (Exception e)
{
System.out.println("String date exception "+e);
}
Ex: 2019-05-25 00:00:00.0
In order to convert the date format from yyyy-MM-dd hh:mm:ss.S to dd-MMM-yyyy, use the below piece of snippet.
Code to handle the Date Conversion:
import java.text.SimpleDateFormat;
String convStr1=null;
OAMessageDateFieldBean par1=(OAMessageDateFieldBean )webBean.findIndexedChildRecursive("crTargetFrom");
Timestamp TargetFrom = (Timestamp)par1.getValue(pageContext);
System.out.println("Target From :"+TargetFrom);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
SimpleDateFormat formatDate = new SimpleDateFormat("dd-MMM-yyyy");
try
{
java.util.Date dateStr1 = format.parse(TargetFrom.toString());
convStr1 = formatDate.format(dateStr1);
System.out.println("String date Converted : "+convStr1);
}
catch (Exception e)
{
System.out.println("String date exception "+e);
}
No comments:
Post a Comment