User Story
As a software developer integrating date-related functionalities into our application,
I want a utility method that converts a month's name to its corresponding numeric representation,
So that I can seamlessly handle date inputs in different formats across the system.
Codes
public class DateUtility {
public static Integer GetMonthInNumber(string monthInWord){
switch on monthInWord {
when 'January'{
return 1;
}
when 'February'{
return 2;
}
when 'March'{
return 3;
}
when 'April'{
return 4;
}
when 'May'{
return 5;
}
when 'June'{
return 6;
}
when 'July'{
return 7;
}
when 'August'{
return 8;
}
when 'September'{
return 9;
}
when 'October'{
return 10;
}
when 'November'{
return 11;
}
when 'December'{
return 12;
}
When else{
return null;
}
}
}
}