To convert String to Date in salesforce

The below simple code is used to convert String to Date data type using Apex

Sample Code:

String todate = '12/27/2013';
Date dt = Date.valueOf(todate);


Cheers!!!

4 comments:

  1. it occur runtime error Invalid date

    ReplyDelete
  2. Use Date.parse(todate) instead

    ReplyDelete
  3. Use :

    String todate = '12/27/2013';
    Date dt = Date.parse(todate);

    ReplyDelete
  4. showing error

    ReplyDelete