B4J Question DataPicker: Problem with DateFormat?

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
Defining the date format as "dd/MM/yy" works as the input value for the DatePicker, but when you select the desired date on the calendar, the value it returns is always in the format MM/dd/yy regardless of whether You have previously changed it.
 
Please upload a small example that reproduces it.

Is the original CustomElements example, only with DateFormat added.

Public Sub Initialize
DateTime.DateFormat = "dd/MM/yyyy"
End Sub
 

Attachments

  • CustomElements.zip
    CustomElements.zip
    3.8 KB · Views: 344
  • Captura1.PNG
    Captura1.PNG
    5.9 KB · Views: 389
  • Captura2.PNG
    Captura2.PNG
    17.3 KB · Views: 490
  • Captura3.PNG
    Captura3.PNG
    6.2 KB · Views: 435
Upvote 0
In index.html (Objects -> www) :
Code: Copy
    <script>
    //connect to the web socket when the page is ready.
    $( document ).ready(function() {
        //set the date picker and also bind the event.
        $("#datepicker").datepicker({
            onSelect: function(dateText, inst) {
                //raise the event.
                b4j_raiseEvent(this.id + "_select", {});
            },
            showButtonPanel: true,
            dateFormat: "mm/dd/yy"
        });
        b4j_connect("/datepicker/ws");
    });
    </script>
Change dateformat to dd/mm/yy

​
 
Upvote 0
In index.html (Objects -> www) :
Code: Copy
    <script>
    //connect to the web socket when the page is ready.
    $( document ).ready(function() {
        //set the date picker and also bind the event.
        $("#datepicker").datepicker({
            onSelect: function(dateText, inst) {
                //raise the event.
                b4j_raiseEvent(this.id + "_select", {});
            },
            showButtonPanel: true,
            dateFormat: "mm/dd/yy"
        });
        b4j_connect("/datepicker/ws");
    });
    </script>
Change dateformat to dd/mm/yy

​

Thanks.

Solved and working but with a little "trick."

To work correctly, and the date format is the same in the input as in the output, in the B4J code it must be defined as follows:

Code: Copy
Public Sub Initialize
    DateTime.DateFormat = "dd/MM/yyyy"
End Sub

While in the html part, the format has to be:

Code: Copy
dateFormat: "dd/mm/yy"
 
Upvote 0
Back
Top