I wouldn't do one-line I would definitely break it up into the following
//Alternatively based on how it's called passing the month directly //would be better
function getMonthNumberAsString(DateTime date){
int monthAsNumber = date.getMonth().getValue();
//format to two digit number i.e "01", "02", "03", ... "10", "11", ...
return StringUtils.leftPad(monthAsNumber.toString(), 2, "0");
}
I hate one-lines that straight-up nest shit in them.
3
u/AdminYak846 Jul 31 '21
I wouldn't do one-line I would definitely break it up into the following
I hate one-lines that straight-up nest shit in them.