Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

i write a small apex code snippet.

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

        if(Date.valueOf(dataType1) == x)
         conditionsResult.add(true);
         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

1 Answer 1

up vote 3 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 at 12:15

Your Answer

 
discard

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.