You need to sign in to do that
Don't have an account?
Rustyboy
DatePicker format changes when VF page refreshed
Apologies if this has already been answered but I have spent more than an hour looking and still cannot find an answer to my problem:
I am using a datepicker on an apex:inputtext field, to establish a from and to date range. It works fine, but when the screen is refreshed the value in the date changes from:
D/MM/YYY format (what I am after), to something like this:
Mon Jul 15 00:00:00 GMT 2013
Therefore, next time I attempt to perform an action, I get an error message saying:
my mistake!!!!
All Answers
Hi,
Try formatting the date fields in the getters:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other's benefit.
I thought you had the solution then,when I tried it I got the following error message:
Error: Compile Error: Method does not exist or incorrect signature: [Date].format(String) at line 19 column 21
I tried to do it as a DateTime field instaed, but then it insisted on having a time component too.
Any other ideas?
Rusty boy you are close!!!!
Format method of Date class automatically formats the date to user locale.
Hi Avi: Still does not work. I get:
Error: Compile Error: Return value must be of type: Date at line 27 column 13
PS: Also made a change to convert to a DateTime field and return newDate.Date() - same problem as before, with the date format when the page is refreshed
lets do it a different way,
Thanks for sticking with this Avi :o)
The problem with using format() is that it returns a string, but FromDateCriteria is a date, so I get this message:
Error: Compile Error: Return value must be of type: Date at line 106 column 9
Code here for reference:
public date FromDateCriteria;
public date getFromDateCriteria() {
if (FromDateCriteria==null) {
return null;
}
return FromDateCriteria.format();
}
my mistake!!!!
Works perfectly - thanks Avi
public date FromDateCriteria;
public date getFromDateCriteria() {
if (FromDateCriteria==null) {
return null;
}
return FromDateCriteria.format();
}
I get .... Compile Error: Return value must be of type: Date. How else can I fix this?
public void setimplanteddate(Date implanteddate) {
this.implanteddate= implanteddate;
}
public String getimplanteddate() {
if(implanteddate==NULL)
{
return NULL;
}
return implanteddate.format();
}
Hey Guys i tried like this ..but in vf page i am getting this error Read only property 'implanteddate' please help me guys...Thanks advance
Before
<apex:inputText value="{!fromDateCriteria}" size="10" onfocus="DatePicker.pickDate(false, this, false);" id="fromDate" />
After
<apex:input type"date" size="10" value="{!fromDateCriteria}" id="fromDate" />