Custom Date widget format

In Plone 6.0.14 with plone.app.z3cform 4.3.2, I wanted to customize the display format of the date value. However, it seems it does not use the set locale format or the override locale format in the registry. So my solution was to customize the date widget. I used the following code:

interfaces.py:

from plone.app.z3cform.interfaces import IDateWidget as IDateWidgetBase


class ICustomDateWidget(IDateWidgetBase):
    """Custom date widget marker interface"""

custom_date_widget.py:

from plone.app.z3cform.widgets.datetime import DateWidget
from my.package.interfaces import ICustomDateWidget
from z3c.form.interfaces import IFieldWidget
from z3c.form.widget import FieldWidget
from zope.interface import implementer, implementer_only


@implementer_only(ICustomDateWidget)
class CustomDateWidget(DateWidget):

    def render(self):
        if self.mode != "display":
            self.addClass("form-control")
            return super().render()

        if not self.value:
            return ""

        field_value = self._converter(self.field, self).toFieldValue(self.value)
        if field_value is self.field.missing_value:
            return ""

        return field_value.strftime("%d %b %Y")


@implementer(IFieldWidget)
def CustomDateFieldWidget(field, request):
    return FieldWidget(field, CustomDateWidget(request))  

Is there another simpler way? Looking at the p.a.z3cform code, it accepts pattern_options but it does not seem to be used by the display mode of the widget.

If you want to customize the display template of a DatetimeWidget, you could register one with

<z3c:widgetTemplate
      widget="plone.app.z3cform.interfaces.IDatetimeWidget"
      template="templates/my_datetime_display.pt"
      layer="plone.app.z3cform.interfaces.IPloneFormLayer"
      mode="display"
      />

Thank you for your answer. I tested it on my date widget template but it did not work. However, it worked for the text widget which I registered as:

    <z3c:widgetTemplate
        mode="display"
        widget="z3c.form.interfaces.ITextWidget"
        layer="plone.app.z3cform.interfaces.IPloneFormLayer"
        template="text_display.pt"
    />

I think this is because the p.a.z3cform version that I am using has an implementation of the render() method. There is no widget template registered for the display mode. Likely, this is because it is implemented by mockup pattern.