Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static org.junit.Assert.*;
- import java.util.Calendar;
- import org.junit.Before;
- import org.junit.Test;
- public class Tester {
- private static Calendar cacheCalendar;
- public static int getFirstMonday(int year, int month) {
- cacheCalendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
- cacheCalendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, 1);
- cacheCalendar.set(Calendar.MONTH, month);
- cacheCalendar.set(Calendar.YEAR, year);
- return cacheCalendar.get(Calendar.DATE);
- }
- @Before
- public void setUp() throws Exception {
- cacheCalendar = Calendar.getInstance();
- System.err.println("Using calendar " + cacheCalendar);
- }
- @Test
- public void test() {
- assertEquals(6, getFirstMonday(2014, Calendar.JANUARY));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement