You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there are some automatic conversion for BigDecimal, Double and Float
to correctly compare them, but this behaviour is not applied to Date / LocalDate / LocalDateTime / ZonedDateTime
in EL 5.0 (Tomcat 10.1.33) the following expression throws an exception
#{ bean.date lt currentDate }
@Named @Produces @RequestScoped
public java.util.Date getCurrentDate() { return new java.util.Date(); }
@Named
@RequestScoped
public class Bean {
private LocalDate date = LocalDate.now().minusDays(1);
public LocalDate getDate() {
return date;
}
}
The Exception:
java.lang.ClassCastException: class java.util.Date cannot be cast to class java.time.chrono.ChronoLocalDate (java.util.Date and java.time.chrono.ChronoLocalDate are in module java.base of loader 'bootstrap')
at java.base/java.time.LocalDate.compareTo(LocalDate.java:139)
at org.apache.el.lang.ELSupport.compare(ELSupport.java:126)
at org.apache.el.parser.AstLessThan.getValue(AstLessThan.java:45)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:152)
at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
Expected Behavior
something like:
If A or B is LocalDate, coerce both A and B to LocalDate and use the return value of A.compareTo(B)
If A or B is LocalDateTime, coerce both A and B to LocalDateTime and use the return value of A.compareTo(B)
The text was updated successfully, but these errors were encountered:
Reading the 1.9 section of EL spec
https://jakarta.ee/specifications/expression-language/5.0/jakarta-expression-language-spec-5.0#relational-operators
there are some automatic conversion for BigDecimal, Double and Float
to correctly compare them, but this behaviour is not applied to
Date
/LocalDate
/LocalDateTime
/ZonedDateTime
in EL 5.0 (Tomcat 10.1.33) the following expression throws an exception
The Exception:
Expected Behavior
something like:
If A or B is
LocalDate
, coerce both A and B toLocalDate
and use the return value of A.compareTo(B)If A or B is
LocalDateTime
, coerce both A and B toLocalDateTime
and use the return value of A.compareTo(B)The text was updated successfully, but these errors were encountered: