0

I showing date in email that is in string. I want to convert that into DateTime like(dd-mmm-yyyy hh:mm am/pm). I am trying like DateTime.parse() but it won't work. It's failed and shows the message

"First error: Invalid date/time: 2015-11-05"

My code line is:

string  nextDate = (string.valueof(cf.Last_Reviewed_date__c+
              integer.valueof(cf.CF_Section__r.CF_Review_Period__c)).substringbefore(' '));

need convert 'nextdate' date to datetime format and show like 'dd-mmm-yyyy hh:mm am/pm' format. nextdate contains "2015-11-05".

  • are yo using visualforce email template or you are sending through apex ? – Himanshu Oct 29 '15 at 5:41
  • @Himanshu, sending through apex. – Vijay Kumar Oct 29 '15 at 5:48
  • understood. what is this returning integer.valueof(cf.CF_Section__r.CF_Review_Period__c)).substringbefore(' ') ? – Himanshu Oct 29 '15 at 6:01
  • @Himanshu, Date like "2015-11-05". – Vijay Kumar Oct 29 '15 at 6:03
  • I am getting confused. you already have a date cf.Last_Reviewed_date__c and you are concatenating integer.valueOf(cf.CF_Section__r.CF_Review_Period__c) which will return an integer? in that way it is not going to be added because you are using String.valueOf method. so let me know one thing. what is the data type of cf.CF_Section__r.CF_Review_Period__c and one sample value of that. Update your question with these values. – Himanshu Oct 29 '15 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.