You need to sign in to do that
Don't have an account?
Nayana K
Invalid Date time exception only for particular date time
DateTime dtOrigin = DateTime.newInstance(2017, 03, 12, 2, 3, 0);
DateTime startDateOfSchedule = dtOrigin;
String timeVal = ' 02:03';
Date startDate = date.newinstance(startDateOfSchedule.year(), startDateOfSchedule.month(), startDateOfSchedule.day());
system.debug('=dtOrigin=='+dtOrigin);
system.debug('=startDateOfSchedule=='+startDateOfSchedule);
system.debug('=timeVal=='+timeVal);
system.debug('=startDate=='+startDate);
system.debug('=Formatted startDate=='+startDate.format());
DateTime dtVal = DateTime.parse(startDate.format()+''+timeVal);
system.debug('=dtVal=='+dtVal);
I have a problem in VF page for particular date time in apex controller. Above is snippet which I ran in dev console and got same error like appeared in VF.
In the above code, I am getting 'Invalid date/time: 12/03/2017 02:03'
If I change DateTime dtOrigin = DateTime.newInstance(2017, 03, 12, 2, 3, 0); to DateTime dtOrigin = DateTime.newInstance(2017, 03, 13, 2, 3, 0);, I won't get error of invalid datetime while parsing DT and assining into dtVal variable. I wonder, why this behaviour only for this specific date and that too for 2hours:some minutes.
For other date and time combo, there is no error. I find hard time in understanding this.
Please help.
DateTime startDateOfSchedule = dtOrigin;
String timeVal = ' 02:03';
Date startDate = date.newinstance(startDateOfSchedule.year(), startDateOfSchedule.month(), startDateOfSchedule.day());
system.debug('=dtOrigin=='+dtOrigin);
system.debug('=startDateOfSchedule=='+startDateOfSchedule);
system.debug('=timeVal=='+timeVal);
system.debug('=startDate=='+startDate);
system.debug('=Formatted startDate=='+startDate.format());
DateTime dtVal = DateTime.parse(startDate.format()+''+timeVal);
system.debug('=dtVal=='+dtVal);
I have a problem in VF page for particular date time in apex controller. Above is snippet which I ran in dev console and got same error like appeared in VF.
In the above code, I am getting 'Invalid date/time: 12/03/2017 02:03'
If I change DateTime dtOrigin = DateTime.newInstance(2017, 03, 12, 2, 3, 0); to DateTime dtOrigin = DateTime.newInstance(2017, 03, 13, 2, 3, 0);, I won't get error of invalid datetime while parsing DT and assining into dtVal variable. I wonder, why this behaviour only for this specific date and that too for 2hours:some minutes.
For other date and time combo, there is no error. I find hard time in understanding this.
Please help.
This is the problem of your time zone. You can use its as following: Please let me know if you have any query and Mark as answer if you have got.
Thanks
Banwari
Sorry, it din't work.
Please tell me what errors occuring now. This is working for me.You also see log below:
Thanks
Banwari
Time Zone: (GMT-05:00) Eastern Standard Time (America/New_York)
Locale : English (United States)
What's yours?
Its working for me. Can you please share latest code for which you are trying currently. I will analyse your code.
If you check above image, On click of save, it seems like without going to server side controller, this error is coming from client side.