function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Debendra Ray 8Debendra Ray 8 

Invalid Date Error in Visualforce Page

Hi,
I'm getting an Invalid Date Error in a VF Page emanating from the following code :

Date stDate = Date.valueOf((System.currentPageReference().getParameters().get('startDate')));
 Datetime dt = datetime.newInstance(stDate.year(), stDate.month(),stDate.day());
 startDate  = Date.valueOf(dt.format('DD/MM/YYYY'));

Please, could you help me remediate this issue?

Thanks & Regards,

DR
 
bhanu_prakashbhanu_prakash
Hi Debendra,
Mark as best answer, If it resloves !!
startDate  = Date.valueOf(dt.format('DD/MM/YYYY'));
change into 
startDate  = Date.valueOf(dt.format('MM/DD/YYYY'))

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com 
Narender Singh(Nads)Narender Singh(Nads)
Hi Deb,

Use this:
startDate  = dt.format('DD/MM/YYYY');

Let me know if it helps.
Thanks!
bhanu_prakashbhanu_prakash
If this solves your problem, mark the answer as best answer.
Thanks, 
Bhanu Prakash
visit ForceLearn.com