In my controller i try to compare two dates and if it tru return the error message.
Date Today = system.Today();
Date StartDateParsed = Date.parse(startdate);
if(StartDateParsed <= Today){bring ERROR message}
the problem is when the conditional is true it works like it is false. In the debug it shows:
|DEBUG|StartdateP=2016-09-26 00:00:00Today=2016-09-26 00:00:00
Why it doen't work?
Upd:
date dt = system.Today();
String st = dt.format();
startDate = st;
startDate = |DEBUG|startdate=9/26/2016
Upd 2 If i ran this code (And startDate < or = Today):
if(StartDateParsed <= Today){
System.debug ('True');
}
else{
System.debug('False');
}
Debug is True
Upd 3 I have the another page messages that shows correctly:
if (context.Title == NULL){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select the Title for Contact'));
}
but the next code doen't shows the error message at all
if (context.SelectedType == 'Planned' && numberDaysDue >= 0){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please specify the future date'));
system.debug('true');
}
And the debug log says true. This Error message doesn't shows at all, but the rest messages shows fine.
Upd 4 VisualForce section Error messages:
<apex:outputPanel id="messages">
<apex:pageMessages />
</apex:outputPanel>
My save button:
<apex:commandButton id="save" value="Save" action="{!save}" style="padding: 5px;" status="nextActionStatus" reRender="messages,screens,buttons" rendered="{!Context.Type != NULL && Context.Contacts != NULL}"/>
I don't think that the proble is in my vf page, because the rest messages are shown correctly.
Upd 5
if (context.SelectedType == 'Planned' && StartDateParsed <= Today){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please specify the future date'));
}
startDate
string?daysBetween(secondDate)
method developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Can you just give a try with this method? hope this will solve your problem