Last active
November 22, 2022 21:37
-
-
Save jvolkov/20bf22b7744def191d8191ab26faf747 to your computer and use it in GitHub Desktop.
Convert date to a datetime in apex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date today = System.today(); | |
Integer d = today.day(); | |
Integer mo = today.month(); | |
Integer yr = today.year(); | |
DateTime dt = DateTime.newInstance(yr, mo, d); | |
// returns 2022-11-22 08:00:00 | |
Datetime todayWithTime = dt.addHours(12); | |
system.debug(' todayWithTime: ' + todayWithTime); | |
// returns 2022-11-22 20:00:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment