This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new f36dfe96e1 Add coercion to Instant or Date
f36dfe96e1 is described below
commit f36dfe96e105b20a5cca78bac37ab24d00e8577a
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Jul 4 16:55:28 2025 +0100
Add coercion to Instant or Date
---
java/org/apache/el/lang/ELSupport.java | 12 ++++++++++++
webapps/docs/changelog.xml | 4 ++++
2 files changed, 16 insertions(+)
diff --git a/java/org/apache/el/lang/ELSupport.java
b/java/org/apache/el/lang/ELSupport.java
index 9384ded46b..76e541bb4d 100644
--- a/java/org/apache/el/lang/ELSupport.java
+++ b/java/org/apache/el/lang/ELSupport.java
@@ -575,6 +575,18 @@ public class ELSupport {
if (obj == null) {
return null;
}
+
+ if (Instant.class.equals(type)) {
+ @SuppressWarnings("unchecked")
+ T result = (T) coerceToInstant(ctx, obj);
+ return result;
+ }
+ if (Date.class.equals(type)) {
+ @SuppressWarnings("unchecked")
+ T result = (T) Date.from(coerceToInstant(ctx, obj));
+ return result;
+ }
+
if (obj instanceof String str) {
PropertyEditor editor = PropertyEditorManager.findEditor(type);
if (editor == null) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index de4cee0e3f..cdd375fffe 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -213,6 +213,10 @@
<code>TemporalAccessor</code>, <code>Clock</code> and
<code>Date</code>.
(markt)
</add>
+ <add>
+ Add support for coercion to <code>java.time.Instant</code> and
+ <code>java.util.Date</code>. (markt)
+ </add>
<!-- Entries for backport and removal before 12.0.0-M1 below this line
-->
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]