Guest User

Untitled

a guest
Dec 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment