I'm getting the data "StartTime=08:00:00.000Z, EndTime=18:00:00.000Z" and while displaying in page, it should be "08:00 AM , 06:00 PM". How this can do using Apex controller?
I'm getting the data "StartTime=08:00:00.000Z, EndTime=18:00:00.000Z" and while displaying in page, it should be "08:00 AM , 06:00 PM". How this can do using Apex controller?
Best Answer
Looking at the DateTime documentation, you can pass a Java simple date format to the format method.
This is the example straight from the documentation that you can run in anonymous apex to confirm it displays how you'd like.
You pass
h:mm a
whereIf you have to deal with it as a String, you'll have to parse out the hour and minute yourself, but can still utilize the method above by building a DateTime anyway. To give you a rough idea (assuming the String always follows the format you mentioned):