You need to sign in to do that
Don't have an account?
how to format the date and time
hi,
i am having issue of formating the date........
can anybody solve this?
i am retrieving the created date value is like : (Thu Nov 03 09:39:35 GMT 2011)
i want to convert it into this format : (11/2/2011 8:57 AM)
my code is like this:
requirementCommentObj = [select Comment__c, Requirement__c, Commented_By__c,Commented_By__r.Name,createdDate,Name from Requirement_Comment__c];
for(Integer i = 0; i < requirementCommentObj.size(); i++)
{
requirementCommentObj[i].createdDate.format('yyyy-MM-dd HH:mm:ss');
}
return requirementCommentObj;
but this is not working.
any kind of help will be really apriciated......
thanks in advance............
i had the same problem earlier. i think you want to display it on a VF, right?
try this:
<apex:outputText value=" {0,date,dd.MM.yyyy - HH:mm}">
<apex:param value="{!obj.CreatedDate}"/>
</apex:outputText>
with this you get: DD.MM.YYYY - HH:mm
just modify the expression however you want.
All Answers
The format() method returns a String type field. In your code you are not saving the changed format; Try using a String field and display it in your VF page.
String formattedDate = requirementCommentObj[i].createdDate.format('yyyy-MM-dd HH:mm:ss');
return formattedDate;
Use formattedDate in the Visualforce page for display.
Thanks.
i had the same problem earlier. i think you want to display it on a VF, right?
try this:
<apex:outputText value=" {0,date,dd.MM.yyyy - HH:mm}">
<apex:param value="{!obj.CreatedDate}"/>
</apex:outputText>
with this you get: DD.MM.YYYY - HH:mm
just modify the expression however you want.
i got the solution for this by using
<apex:outputText>
my question is already solved.......
thanks for the help....