Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4551

Allowing conversion of RFC3339 dates with date part only (yyyy-MM-dd) as per HTML5 and w3 standard for <input type="date" /> (and others).

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.24
    • 2.3.28
    • Core Actions
    • None

    Description

      Facts:

      • <input type="date" />

        is the HTML5 standard for inputing dates. It works in many browsers: Chrome, Opera, almost every mobile browsers - where it is fundamental - and the coverage can only grow.

      • w3 has chosen the RFC3339 with date only as value format
        yyyy-MM-dd

        while transparently handling the display format according to the Locale.
        This means that, for example, americans see

        MM/dd/yyyy

        , italians see

        dd/MM/yyyy

        , but both of them send

        yyyy-MM-dd

        to the server. Without the time part.

      • Struts Date Converter already works for:
        DateConverter.java
        DateFormat dt1 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale);
        DateFormat dt2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
        DateFormat dt3 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
        
        DateFormat d1 = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        DateFormat d2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
        DateFormat d3 = DateFormat.getDateInstance(DateFormat.LONG, locale);
        
        DateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        

        with a final fallback to

        DateFormat.SHORT

        if nothing worked (in case of Time and Timestamps too).

      My idea is:

      can we add the support for date-only RFC3339, that is the one sent by the browser, in addition to the ones already there ? No existing code would break, and we'd have a standard, automatic conversion for a popular, growing standard.

      I can't see any cons. Can you ?

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            lukaszlenart Lukasz Lenart
            Andrea Ligios Andrea Ligios
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment