List of usage examples for java.util Calendar DECEMBER
int DECEMBER
To view the source code for java.util Calendar DECEMBER.
Click Source Link
From source file:com.wxxr.nirvana.json.JSONInterceptorTest.java
@SuppressWarnings({ "unchecked", "unchecked" }) public void test() throws Exception { // request//from w w w .j av a 2s . co m setRequestContent("json-1.txt"); this.request.addHeader("content-type", "application/json"); // interceptor JSONInterceptor interceptor = new JSONInterceptor(); TestAction action = new TestAction(); this.invocation.setAction(action); this.invocation.getStack().push(action); interceptor.intercept(this.invocation); // serialize and compare List list = action.getList(); assertNotNull(list); assertEquals(list.size(), 10); list = action.getCollection(); assertNotNull(list); assertEquals(list.size(), 3); assertEquals(list.get(0), "b"); assertEquals(list.get(1), 1L); list = (List) list.get(2); assertNotNull(list); assertEquals(list.size(), 2); assertEquals(list.get(0), 10L); assertEquals(list.get(1), 12L); list = action.getCollection2(); assertNotNull(list); assertEquals(list.size(), 1); // inside a map any primitive is either: String, Long, Boolean or Double Map bean = (Map) list.get(0); assertNotNull(bean); assertTrue((Boolean) bean.get("booleanField")); assertEquals(bean.get("charField"), "s"); assertEquals(bean.get("doubleField"), 10.1); assertEquals(bean.get("floatField"), 1.5); assertEquals(bean.get("intField"), 10L); assertEquals(bean.get("longField"), 100L); assertEquals(bean.get("stringField"), "str"); bean = (Map) bean.get("objectField"); assertNotNull(bean); assertFalse((Boolean) bean.get("booleanField")); assertEquals(bean.get("charField"), "\u0000"); assertEquals(bean.get("doubleField"), 2.2); assertEquals(bean.get("floatField"), 1.1); assertEquals(bean.get("intField"), 0L); assertEquals(bean.get("longField"), 0L); assertEquals(bean.get("stringField"), " "); assertEquals(action.getFoo(), "foo"); Map map = action.getMap(); assertNotNull(map); assertEquals(map.size(), 2); assertEquals(map.get("a"), 1L); list = (List) map.get("c"); assertNotNull(list); assertEquals(list.size(), 2); assertEquals(list.get(0), 1.0); assertEquals(list.get(1), 2.0); assertEquals(action.getResult(), null); Bean bean2 = action.getBean(); assertNotNull(bean2); assertTrue(bean2.isBooleanField()); assertEquals(bean2.getStringField(), "test"); assertEquals(bean2.getIntField(), 10); assertEquals(bean2.getCharField(), 's'); assertEquals(bean2.getDoubleField(), 10.1); assertEquals(bean2.getByteField(), 3); String[] strArray = action.getArray(); assertNotNull(strArray); assertEquals(strArray.length, 2); assertEquals(strArray[0], "str0"); assertEquals(strArray[1], "str1"); int[] intArray = action.getIntArray(); assertNotNull(intArray); assertEquals(intArray.length, 2); assertEquals(intArray[0], 1); assertEquals(intArray[1], 2); Bean[] beanArray = action.getBeanArray(); assertNotNull(beanArray); assertNotNull(beanArray[0]); assertEquals(beanArray[0].getStringField(), "bean1"); assertNotNull(beanArray[1]); assertEquals(beanArray[1].getStringField(), "bean2"); Calendar calendar = Calendar.getInstance(); calendar.setTime(action.getDate()); assertEquals(calendar.get(Calendar.YEAR), 1999); assertEquals(calendar.get(Calendar.MONTH), Calendar.DECEMBER); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 31); assertEquals(calendar.get(Calendar.HOUR), 11); assertEquals(calendar.get(Calendar.MINUTE), 59); assertEquals(calendar.get(Calendar.SECOND), 59); calendar.setTime(action.getDate2()); assertEquals(calendar.get(Calendar.YEAR), 1999); assertEquals(calendar.get(Calendar.MONTH), Calendar.DECEMBER); assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 31); // test desrialize=false assertNull(action.getFoo2()); }
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetFirstDateOfWeekFRBetween2Years() { Date dateTest = DateUtil.getFirstDateOfWeek(java.sql.Date.valueOf("2013-12-31"), "fr"); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.DECEMBER)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(30)); assertThat(cal.get(Calendar.HOUR_OF_DAY), is(0)); assertThat(cal.get(Calendar.MINUTE), is(0)); assertThat(cal.get(Calendar.SECOND), is(0)); assertThat(cal.get(Calendar.MILLISECOND), is(0)); }
From source file:de.gebatzens.sia.SIAApp.java
public String getSeasonTheme() { int m = Calendar.getInstance().get(Calendar.MONTH); switch (m) {/* w ww. j a va 2 s. co m*/ case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: return "Winter"; default: return "Summer"; } }
From source file:org.apache.james.protocols.imap.utils.DecoderUtilsTest.java
@Test public void testDecodeMonth() throws Exception { assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('J', 'A', 'N')); assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('j', 'a', 'n')); assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('F', 'E', 'B')); assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('f', 'e', 'b')); assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('M', 'A', 'R')); assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('m', 'a', 'r')); assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('A', 'P', 'R')); assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('a', 'p', 'r')); assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('M', 'A', 'Y')); assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('m', 'a', 'y')); assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('J', 'U', 'N')); assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('j', 'u', 'n')); assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('J', 'U', 'L')); assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('j', 'u', 'l')); assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('A', 'U', 'G')); assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('a', 'u', 'g')); assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('S', 'E', 'P')); assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('s', 'e', 'p')); assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('O', 'C', 'T')); assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('o', 'c', 't')); assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('N', 'O', 'V')); assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('n', 'o', 'v')); assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('D', 'E', 'C')); assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('d', 'e', 'c')); }
From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java
private int month(String sMonth) { if (isEmpty(sMonth)) { return -1; }/* w w w .jav a 2s . c o m*/ if (sMonth.length() < 3) { return -1; } String prefix = sMonth.substring(0, 3).toLowerCase(); MONTH m = MONTH.fromString(prefix); if (m == null) { return -1; } switch (m) { case JANUARY: return Calendar.JANUARY; case FEBRUARY: return Calendar.FEBRUARY; case MARCH: return Calendar.MARCH; case APRIL: return Calendar.APRIL; case MAY: return Calendar.MAY; case JUNE: return Calendar.JUNE; case JULY: return Calendar.JULY; case AUGUST: return Calendar.AUGUST; case SEPTEMBER: return Calendar.SEPTEMBER; case OCTOBER: return Calendar.OCTOBER; case NOVEMBER: return Calendar.NOVEMBER; case DECEMBER: return Calendar.DECEMBER; default: return -1; } }
From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java
@Test public void testWindowsNTSystem() { FTPFileEntryParser parser = new FTPParserSelector().getParser("Windows_NT version 5.0"); FTPFile parsed;//from w ww .j a va 2 s . c om // #5505 parsed = parser.parseFTPEntry( "drwxrwxrwx 1 owner group 0 Dec 5 0:45 adele.handmadebyflloyd.com"); assertNotNull(parsed); assertEquals("adele.handmadebyflloyd.com", parsed.getName()); assertEquals("owner", parsed.getUser()); assertEquals("group", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(5, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); // #5505 parsed = parser.parseFTPEntry("drwxrwxrwx 1 owner group 0 Jan 22 2009 contact"); assertNotNull(parsed); assertEquals("contact", parsed.getName()); assertEquals("owner", parsed.getUser()); assertEquals("group", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.JANUARY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(22, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2009, parsed.getTimestamp().get(Calendar.YEAR)); }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
public static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: // This is not correct. See isLeapYear(int) above //return (year % 4 == 0) ? 29 : 28; return isLeapYear(year) ? 29 : 28; default:// w w w . j av a 2 s. c om throw new IllegalArgumentException("Invalid Month"); } }
From source file:agency.AgencyManagerImplTest.java
private static Agent newAgent02() { Calendar cal = new GregorianCalendar(1982, Calendar.DECEMBER, 5); return newAgent("Black widow", cal.getTime(), 2, "One of the Avengers"); }
From source file:br.msf.commons.util.AbstractDateUtils.java
protected static Collection<Calendar> getBrasilianHolidays(final int year) { Collection<Calendar> holidays = new ArrayList<>(); // feriados fixos holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal // feriados calculados Calendar pascoa = getSundayOfEaster(year); Calendar carnaval = (Calendar) pascoa.clone(); carnaval.add(Calendar.DAY_OF_MONTH, -47); Calendar corpusChristi = (Calendar) pascoa.clone(); corpusChristi.add(Calendar.DAY_OF_MONTH, 60); holidays.add(carnaval); // Carnaval holidays.add(pascoa); // Pascoa holidays.add(corpusChristi); // Corpus Christi return holidays; }
From source file:br.ojimarcius.commons.util.AbstractDateUtils.java
protected static Collection<Calendar> getBrasilianHolidays(final int year) { Collection<Calendar> holidays = new ArrayList<Calendar>(); // feriados fixos holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal // feriados calculados Calendar pascoa = getSundayOfEaster(year); Calendar carnaval = (Calendar) pascoa.clone(); carnaval.add(Calendar.DAY_OF_MONTH, -47); Calendar corpusChristi = (Calendar) pascoa.clone(); corpusChristi.add(Calendar.DAY_OF_MONTH, 60); holidays.add(carnaval); // Carnaval holidays.add(pascoa); // Pascoa holidays.add(corpusChristi); // Corpus Christi return holidays; }