B4J Question DataPicker: Problem with DateFormat?

Gabino A. de la Gala

Active 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.
 

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
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
    3.8 KB · Views: 139
  • Captura1.PNG
    Captura1.PNG
    5.9 KB · Views: 151
  • Captura2.PNG
    Captura2.PNG
    17.3 KB · Views: 150
  • Captura3.PNG
    Captura3.PNG
    6.2 KB · Views: 146
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
In index.html (Objects -> www) :
B4X:
    <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

Gabino A. de la Gala

Active Member
Licensed User
Longtime User
In index.html (Objects -> www) :
B4X:
    <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:

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

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

B4X:
dateFormat: "dd/mm/yy"
 
Upvote 0
Top