Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EL: Compare two dates

rade.todorovichJul 10 2015 — edited Jul 13 2015

JDeveloper 12.1.3

I want to render certain component based on the two date comparison, something like:

<af:outputText value="(Expired)" id="ot3" inlineStyle="color:Red; font-weight:bold;"

                       rendered="#{now > bindings.EndDate.inputValue}"/>

"now" is java.util.Date from the registered managed bean (fine with ADF/JSF layer) while the above EndDate is coming from VO(based on EO) and is by default java.sql.Timestamp so cannot quite compare the two.

What is the recommended way to do this?

I was able to create a bean:

public class NowTimestamp {

     private Timestamp now;

    public void setNow(Timestamp now) {

        this.now = now;

    }

    public Timestamp getNow() {

        java.util.Date date = new java.util.Date();

        return new Timestamp(date.getTime());

    }

}

and then use rendered="#{datebean.now > bindings.EndDate.inputValue}" but then read that it is not recommended to have sql.Timestamp in the UI.

This post has been answered by Florin Marcus on Jul 10 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 10 2015
Added on Jul 10 2015
4 comments
1,136 views