Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i write a small apex code snippet.

if(v.dataType == 'Date')
    {  System.debug('date is'+mapField.get(;
        System.debug('field is'+field1);
        String str = mapField.get(;
        Date x;
        if(str ==null)
        x= Date.newInstance(str.split('\\')[2],str.split('\\')[0],str.split('\\')[1]);

        if(Date.valueOf(dataType1) == x)
         else conditionsResult.add(false);

on line x= Date.newInstance(str.split('\\')[2],str.split('\\')[0],str.split('\\')[1]); its giving me error

Variable does not exist: Date

but date is a global object i think.please help how to remove this error ??

share|improve this question
up vote 8 down vote accepted

Date.newInstance does not accept strings, it accepts integers according to the documentation. You are passing in Strings.

You could possibly try the Date.parse method.

share|improve this answer
thanks a lot :) – user133421 Jul 19 '14 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.