Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.glassfish.mojarra.facelets.tag.faces.core;

import java.util.Set;
import java.util.TimeZone;

import jakarta.el.ELException;
Expand Down Expand Up @@ -44,6 +45,14 @@
*/
public final class ConvertDateTimeHandler extends ConverterHandler {

/**
* The values of the {@code type} attribute which represent a {@code java.time} class, as listed in
* {@link DateTimeConverter#setType(String)}. Only for these may {@code pattern} and {@code type} co-exist.
*/
private static final Set<String> JAVA_TIME_TYPES = Set.of(
"localDate", "localDateTime", "localTime", "offsetTime", "offsetDateTime", "zonedDateTime",
"instant", "year", "yearMonth", "monthDay");

private final TagAttribute dateStyle;

private final TagAttribute locale;
Expand Down Expand Up @@ -94,7 +103,7 @@ public void setAttributes(FaceletContext ctx, Object obj) {
// for java.time values
if (type != null) {
String typeStr = type.getValue(ctx);
if (isJavaTimeType(typeStr)) {
if (JAVA_TIME_TYPES.contains(typeStr)) {
c.setType(typeStr);
}
}
Expand Down Expand Up @@ -127,16 +136,6 @@ public void setAttributes(FaceletContext ctx, Object obj) {
}
}

private static boolean isJavaTimeType(String type) {
boolean result = false;
if (null != type && type.length() > 1) {
char c = type.charAt(0);
result = c == 'l' || c == 'o' || c == 'z';
}

return result;
}

@Override
public MetaRuleset createMetaRuleset(Class<?> type) {
return super.createMetaRuleset(type).ignoreAll();
Expand Down
Loading