Friday, July 10, 2015

ADF: Date & Time

Provided different examples to get date & time in ADF.

Current Database Date: DBTransaction.currentDbTime
Current Date: adf.currentDate
Current DateTime: adf.currentDateTime
Add Dates to Current Date:

Find AM or PM: 
returns 0 for AM & 1 for PM

Get Today's date:
Date d = new Date(Date.getCurrentDate())

Get todays Timestamp:    
Timestamp myTimestamp = new Timestamp((new java.util.Date()).getTime());

Get the database time and set VO attirbute:
vo.setAttribute("OrderDate", ((DBTransactionImpl)getDBTransaction()).getCurrentDbTime());

Get current database time in the middle tier:

Get current time as java.sql.Date:
new java.sql.Date(((DBTransactionImpl)(this.getDBTransaction())).getCurrentDbTime().getTime());

Get Date value in Page/Fragments:
Add following values to adfc-config.xml or taskflow.xml:


And refer as below
<af:outputText value="#{currentDate}">    
<f:convertDateTime pattern="MM/dd/yyyy" type="date"/>

No comments:

Post a Comment

Provide your thoughts !