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
SFDC Forum 007SFDC Forum 007 

Time format representation format

Hi,

 

 I want to represent the time in hh:mm format , i am using the following code below,

 

 if(callReppaMap.get(ac.personContactId)!=null){
                    DateTime dt=System.now();
                    String dtStr=dt.format('HH:mm');
                    paDet.crdate=String.valueof(callReppaMap.get(ac.pe

rsonContactId).Date__c);
                    }else{
                        paDet.crdate='';

                    }

 

but i am getting the date as well as time, please help me with my issue.

 

 

Thanks in Advance

Best Answer chosen by Admin (Salesforce Developers) 
ManjunathManjunath

Hi!!

 

If so use this, it might work.

 

if(callReppaMap.get(ac.personContactId)!=null){
                    paDet.crdate=String.valueof(callReppaMap.get(ac.personContactId).Date__c.format('hh:mm a'));

                    }else{
                        paDet.crdate='';

                    }

 

With Regards,

Manjunath 

All Answers

ManjunathManjunath

Hi!!

 

Is Date__c is your datetime field.

 

Thanks 

Manjunath

SFDC Forum 007SFDC Forum 007

Yes, correct , Date__c is a date/time field

ManjunathManjunath

Hi!!

 

If so use this, it might work.

 

if(callReppaMap.get(ac.personContactId)!=null){
                    paDet.crdate=String.valueof(callReppaMap.get(ac.personContactId).Date__c.format('hh:mm a'));

                    }else{
                        paDet.crdate='';

                    }

 

With Regards,

Manjunath 

This was selected as the best answer
SFDC Forum 007SFDC Forum 007

Thanks a lot dude,It worked.