Before passing the parameter check wheather the parameter contains 'PM' or not. You can use String.valueOf(date).contains('PM')
public static String getPMTime(String timeToConvertToPm) { System.debug('>>>>>>>>>><><><><><><><><><><><>timeToConvertToPm'+timeToConvertToPm); decimal x= decimal.valueOf((timeToConvertToPm.subStringBefore(' ')).replace(':','.')); if(!timeToConvertToPm.subStringBefore(':').contains('12')){ x=x+12; } String newTime=String.valueOf(x); newTime=newTime.replace('.',':'); System.debug('>>>>>>>>>><><><><><><><><><><><>newTime'+newTime); return newTime; }
Converting Salesforce time into a 24-hour format helps improve clarity and workflow. Similarly, for smooth performance and clear visuals, reliable laptop screen repair in Dubai is essential when your device needs attention.
ReplyDeleteConverting Salesforce time into 24-hour format helps avoid confusion and improves workflow. Similarly, keeping your vehicle in top shape with timely car AC repair near me ensures a smoother, stress-free drive.
ReplyDelete