on 12-11-2023 10:41 AM
Hi Folks,
I have written a code which is working fine for one date picker but not working for the other date picker. I know the issue is relate to the format of the date but don't know how to fix it can anyone please help.
The code for this is here
Code For View<VBox class="sDateVbox"> <Label text="Start Date" required="true"/> <DatePicker id="datePicker" value="{oMainModel>/startDateSetupModel}" displayFormat="MM yyyy" valueFormat="dd-MM-yyyy" change="_startDateChange"/> </VBox> <VBox class="eDateVbox"> <Label text="End Date" required="true"/> <DatePicker value="{oMainModel>/endDateSetupModel}" displayFormat="MM yyyy" valueFormat="dd-MM-yyyy" change="_endDateChange" minDate="{oMainModel>/minEndDate}"/> </VBox>Code of the controller:-_startDateChange: function (oEvent) { var year = parseInt(oEvent.mParameters.value.split("-")[2]); var month = parseInt(oEvent.mParameters.value.split("-")[1]); var formt = sap.ui.core.format.DateFormat.getInstance({ pattern: "MM/dd/yyyy" }); this.oMainModel.setProperty("/startDateSetupModel", formt.format(new Date(year, month - 1, 1))); this.oMainModel.setProperty("/minEndDate", new Date(formt.format(new Date(year, month - 1, 1)))); // this.oMainModel.setProperty("/startDateSetupModel", formt.format(new Date(oEvent.mParameters.value))); },The issue is whenever I try to set the start date it automatically sets to the 01 2023 instead of that I want it in a format like the
End Date
End Date is working fine. While debugging I found that if in this line
this.oMainModel.setProperty("/startDateSetupModel", formt.format(new Date(year, month - 1, 1)));
If I change the last parameter of the new Date to any number greater than 12 like 13
this.oMainModel.setProperty("/startDateSetupModel", formt.format(new Date(year, month - 1, 13)));
than it works fine. But I am not able to set it to any number below 12. Can anyone help me with this.
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.