function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kito kidkito kid 

Datetime picker value format change after submit the form

I am using JS like below,

 

function DynamicDatePicker(d_id)
{
    DatePicker.pickDate(false,d_id.id,false);
}

 

 

 <apex:inputText id="startDate" value="{!startDate}" onfocus="DynamicDatePicker(this);"
                     size="20" disabled="false" style="width:80px;"/>

 

 

At inital , when user select from picker, value displays as 04/07/2013 (DD/MM/YYYY).

But after user submits the form, the value from the picker changes as [Thu Jul 04 00:00:00 GMT 2013].

 

How I can force the date time picker only displayed as DD/MM/YYYY ?

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

Well try this

private Date StartDate;

public void setStartDate(Date FromDateCriteria) {
    this.StartDate = StartDate;
}
public String getStartDate() {
    //you can put a null check here  
    return StartDate.format();
}

I answered the same here http://boards.developerforce.com/t5/Visualforce-Development/DatePicker-format-changes-when-VF-page-refreshed/m-p/650577#M66851

 

 

All Answers

Avidev9Avidev9

Well try this

private Date StartDate;

public void setStartDate(Date FromDateCriteria) {
    this.StartDate = StartDate;
}
public String getStartDate() {
    //you can put a null check here  
    return StartDate.format();
}

I answered the same here http://boards.developerforce.com/t5/Visualforce-Development/DatePicker-format-changes-when-VF-page-refreshed/m-p/650577#M66851

 

 

This was selected as the best answer
kito kidkito kid
Hi Avidev9,
I tried to follow ur code, I am facing one problem.
After the form is submitted , the date become null .
Any hint?
Avidev9Avidev9
Should work ! Because I tried this earlier. Can you post your code ?
kito kidkito kid

Hi Avidev9,

my mistake, I was using the different variable name. Thanks again.