1

I have my date coming in through the page parameters:

custDelDate = ApexPages.currentPage().getParameters().get('delDate'); 

I converted this to date since one of my column in the table requires a date datatype. I did this by the below step:

custDeliveryDate = Date.parse(custDelDate);

Now, in my table it looks as below:

Tue Dec 30 00:00:00 GMT 2014.

I can format the date to mm/dd/yyyy and this returns me a strting, but I need a date datatype(with format dd/mm/yyyy) to suffice the below need of my inputText in the VisualForce page:

<apex:column headerValue="RRD Approved Start">
<apex:inputText id="rrdApprovedStart"     value="{!d.rrdApprovedStart}"  
onfocus="DatePicker.pickDate(true, '{!$Component.rrdApprovedStart}',    false);"/>  
<c:DatePickerComponent dateFieldId="{!$Component.rrdApprovedStart}" /> –

Please help me with this. I am so badly stuck with this issue.

Thanks, Priyanka

2
  • Sorry missed the input text format in my vf page: <apex:column headerValue="RRD Approved Start"> <apex:inputText id="rrdApprovedStart" value="{!d.rrdApprovedStart}" onfocus="DatePicker.pickDate(true, '{!$Component.rrdApprovedStart}', false);"/> <c:DatePickerComponent dateFieldId="{!$Component.rrdApprovedStart}" />
    – user10930
    Commented Nov 17, 2014 at 19:29
  • I am unsure what you want to achieve here. If you have a Date field in your object, it will contain date. The format of that date is irrelevant during storage. It can be converted as required.. When you mention how the data looks in your table, how did you find this out?
    – FrankZ
    Commented Nov 17, 2014 at 20:10

3 Answers 3

3

Instead of using a custom formatted date and a call to a Javascript Datepicker function, I would use an Apex controller with a reference to a particular date field. Then in your Visualforce page, you would reference the date field with <apex:inputField value="{!myObj.MyDateField__c}" /> and it will take care of the formatting, date picking for you.

If you don't have a field you can use in your controller, you could always instantiate a standard record with a date field, (say Contact and Birthdate), and use those to pass the information back and forth from the Apex controller to the VF page.

1
  • 1
    I used this approach. I have 6 different rows with one column the date field in my page block table. The date column is defaulted to (myobj.MyDateField__c).. I have a submit button and once i click on submit i have to do some calculations and want to update the 6th row date column.. but once i do calculations and update myobj.MyDateField__c and re render the table on submit it updates all the 6 rows.... how do i just update the 6th row date column alone?
    – user10930
    Commented Nov 17, 2014 at 22:09
3

If you want to display date in dd/mm/yyyy format regardless of the format stored in backend then just follow below

<apex:column headerValue="BirthDate">
        <apex:outputText value="{0,date,dd-MM-yyyy}">
                   <apex:param value="{!Mem.Birthdate__c}" />
         </apex:outputText>
  </apex:column>

I hope this might help you.

0

I used this approach which made it even more simpler:

For a date picker, which accepts string:

<apex:inputText value="{!d.approvedStart}" size="10" id="approvedStart" onfocus="DatePicker.pickDate(false, this , false);"  />

I had to make sure the version of the page is 28. And approvedStart is a string in the controller. This made it work.

You must log in to answer this question.

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