You need to sign in to do that
Don't have an account?
Aman Gupta 74
Unable to get value of date in Apex class from VisualForce page's date picker
Hi All,
Visual Force Code:
<apex:input type="date" value="{!date}" styleclass="myStyle"/>
Apex Class Code:
public String date{get;set;}
public string getdate() {
return date;
}
public void setdate(string date) {
this.date= date;
}
NOTE: I have tried using Date datatype as well instead of string, still unable to get the selected value of date from VF page in Apex Class.
Kindly, help.
Thank!
Aman
Visual Force Code:
<apex:input type="date" value="{!date}" styleclass="myStyle"/>
Apex Class Code:
public String date{get;set;}
public string getdate() {
return date;
}
public void setdate(string date) {
this.date= date;
}
NOTE: I have tried using Date datatype as well instead of string, still unable to get the selected value of date from VF page in Apex Class.
Kindly, help.
Thank!
Aman
Can please try below code.
Please le me know if it is useful (or) Any help required.
Thanks& Regards
Madhukar_Heptarc.
Please try the below test class and let me know if this works for you. If still need modifications do let me know.
Vf Pgae:
<apex:page controller = "DatePickerValue" docType="html-5.0">
<apex:slds />
<apex:form>
<apex:input type="date" value="{!selected_date}" />
<apex:commandButton value="getDate" action="{!getDate}"/>
</apex:form>
</apex:page>
Controller:
public class DatePickerValue {
public Date selected_date{get;set;}
public void getDate() {
System.debug('Selected Date'+selected_date);
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi