Created
July 24, 2012 21:46
-
-
Save alan-morey/3172879 to your computer and use it in GitHub Desktop.
Apex ScheduleUtil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class ScheduleUtil { | |
global static String cronExpression(DateTime dt) { | |
return dt.format('s m H d M ? yyyy'); | |
} | |
static testMethod void testCronExpression() { | |
DateTime dt = DateTime.now(); | |
String expected = dt.second() + ' ' + dt.minute() + ' ' + dt.hour() + ' ' + dt.day() + ' ' + dt.month() + ' ? ' + dt.year(); | |
System.assertEquals(expected, cronExpression(dt)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment