Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Takes the desired month (as an integer), gives the first of that month in the current FY
- public static date giveMonthInFY(integer monthInt) {
- date dateToReturn;
- if (System.today().Month() >= 7) {
- dateToReturn = date.newinstance(Date.Today().Year(), monthInt, 1);
- }
- else {
- dateToReturn = date.newinstance(Date.Today().Year(), monthInt, 1)-365;
- }
- return dateToReturn;
- }
- @isTest
- public static void testgiveMonthInFY(){
- date testDate3 = Date.newinstance(2018, 01,01);
- date sept1 = StarWarsTestDataUtil.giveMonthInFY(9);
- system.assertEquals(Date.newinstance(2017, 09, 01), sept1);
- date testDate4 = Date.newinstance(2018, 07,01);
- date sept1FY19 = StarWarsTestDataUtil.giveMonthInFY(9);
- system.assertEquals(Date.newinstance(2018, 09, 01), sept1FY19);
- }
Add Comment
Please, Sign In to add comment