You need to sign in to do that
Don't have an account?
Create Datetime from Date field and text (time) field
I have just started learning APEX but have old C , basic experience.
I am trying to use a date field and time field for my object to allow smoother input of scheduling appointments. I have converted the date to startdate string and time is already a string - I can combine both and was using Valueof method to create the datetime field but the format is invalid as datetime wants yyyy-mm-dd hh:mm:ss and my string is coming out mm/dd/yyyy hh:mm AM or PM.
I guess i can break everything down to day, month, year and then reconstruct but hoped there was a less cumbersome way. Want the date / time input to input the way the default event page does it.
Any help for this APEX novice is appreciated
Unfortunately I think you are out of luck here. The datetime parse expects the String to be in a specific format - there's no additional version of the method that allows you to specify the format.
Hi this class should do what your asking: