I have the following class which is not the controller

    String frequency = 'Daily';
    DateTime dateNow = System.now();
    Date startDate = date.newInstance(dateNow.month(),dateNow.day(),dateNow.year());

    public List<SelectOption> getFrequencyType(){
        List<SelectOption> options=new List<SelectOption>();
        options.add(new SelectOption('Daily','Daily'));
        options.add(new SelectOption('Weekly','Weekly'));
        options.add(new SelectOption('Monthly','Monthly'));
        options.add(new SelectOption('Yearly','Yearly'));
        return options;
    public String getFrequency(){
        return frequency;

    public void setFrequency(String frequency){

    public void setStartDate(Date startDate){
    public Date getStartDate(){
        return startDate;

I want to get Date on the vf page as I get on a visualforce input field when we point it to an SObject. But since I am trying to get the date from the class salesforce gives an error that input field can be only of SObject. Below is the visualforce page

 <apex:pageBlockSectionItem  rendered="{!displayFrequencySection}">
     <inputField value="className.startDate" ></inputField>

In this className has been instantiated in the controller. any help on how to display Date in visualforce inputfield without using SObject.

2 Answers 2


you could use the html 5.0 to get the date picker when you dont refer to the sobject fields.

To your vf page, add doctype attribute on apex:page tag like below:

<apex:page docType="html-5.0" />

and use a date type in the input field:

<apex:input type="date" id="dateid">

You can't use apex:inputfield without sObject field. So what you can do is use apex:input type="date" and set your page to html 5.0 using docType="html-5.0"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .