SHARE
TWEET

Untitled

a guest Dec 16th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // First I output 2018-12-01 00:00:00 as a date
  2. currentDate = Date.today().toStartofMonth();
  3.  
  4. // Outputs 2018-12-01 as a string
  5. firstDayOfCurrentMonth = currentDate.addMonths(i).toStartofMonth();
  6. String currentDateString = String.valueOf(firstDayOfCurrentMonth).removeEnd('00:00:00');
  7.    
  8. // Outputs 2018-12-01 00:00:00
  9. Date.valueOf(currentDateString);
  10.  
  11. // Outputs 2018-12-01 00:00:00
  12. Date.valueOf(currentDateString.removeEnd(' 00:00:00'))
  13.  
  14. Date.parse(currentDateString)
  15. // Throws error with Invalid Date : 2018-12-01
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top