I have to format string day='11/22/1999' into '2020-11-26T00:00:00-05:00' this String format with default time value as 0 in apex. please let me know if anyone worked on this.
This will output in the running user's time zone.
System.debug(formatDate('11/22/1999')); //1999-11-22T00:00:00-05:00 String formatDate(String dateString) { Date d = Date.parse(dateString); Datetime dt = Datetime.newInstance(d.year(), d.month(), d.day(), 0, 0, 0); return dt.format('yyyy-MM-dd'T'HH:mm:ssXXX'); }
2.1m questions
2.1m answers
60 comments
57.0k users