List of usage examples for java.util Calendar APRIL
int APRIL
To view the source code for java.util Calendar APRIL.
Click Source Link
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetFirstDateOfMonth() { Date dateTest = DateUtil.getFirstDateOfMonth(java.sql.Date.valueOf("2013-04-20")); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(1)); 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:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetEndDateOfMonth() { Date dateTest = DateUtil.getEndDateOfMonth(java.sql.Date.valueOf("2013-04-20")); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(30)); assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23)); assertThat(cal.get(Calendar.MINUTE), is(59)); assertThat(cal.get(Calendar.SECOND), is(59)); assertThat(cal.get(Calendar.MILLISECOND), is(999)); }
From source file:org.techytax.util.DateHelper.java
public static boolean isTimeForUsingLatestYearPeriod() { Date currentDate = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime(currentDate);//from w w w . j a v a2 s . c om cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 31); Date beginDate = cal.getTime(); cal.set(Calendar.MONTH, Calendar.APRIL); cal.set(Calendar.DAY_OF_MONTH, 1); Date endDate = cal.getTime(); return currentDate.after(beginDate) && currentDate.before(endDate); }
From source file:com.gemstone.gemfire.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java
public static void doPutsInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);//from w ww. ja v a2s. co m Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME); //put person object final Person person1 = new Person(101L, "Mithali", "Dorai", "Raj", DateTimeUtils.createDate(1982, Calendar.DECEMBER, 4), Gender.FEMALE); final Person person2 = new Person(102L, "Sachin", "Ramesh", "Tendulkar", DateTimeUtils.createDate(1975, Calendar.DECEMBER, 14), Gender.MALE); final Person person3 = new Person(103L, "Saurabh", "Baburav", "Ganguly", DateTimeUtils.createDate(1972, Calendar.AUGUST, 29), Gender.MALE); final Person person4 = new Person(104L, "Rahul", "subrymanyam", "Dravid", DateTimeUtils.createDate(1979, Calendar.MARCH, 17), Gender.MALE); final Person person5 = new Person(105L, "Jhulan", "Chidambaram", "Goswami", DateTimeUtils.createDate(1983, Calendar.NOVEMBER, 25), Gender.FEMALE); region.put("1", person1); region.put("2", person2); region.put("3", person3); region.put("4", person4); region.put("5", person5); final Person person6 = new Person(101L, "Rahul", "Rajiv", "Gndhi", DateTimeUtils.createDate(1970, Calendar.MAY, 14), Gender.MALE); final Person person7 = new Person(102L, "Narendra", "Damodar", "Modi", DateTimeUtils.createDate(1945, Calendar.DECEMBER, 24), Gender.MALE); final Person person8 = new Person(103L, "Atal", "Bihari", "Vajpayee", DateTimeUtils.createDate(1920, Calendar.AUGUST, 9), Gender.MALE); final Person person9 = new Person(104L, "Soniya", "Rajiv", "Gandhi", DateTimeUtils.createDate(1929, Calendar.MARCH, 27), Gender.FEMALE); final Person person10 = new Person(104L, "Priyanka", "Robert", "Gandhi", DateTimeUtils.createDate(1973, Calendar.APRIL, 15), Gender.FEMALE); final Person person11 = new Person(104L, "Murali", "Manohar", "Joshi", DateTimeUtils.createDate(1923, Calendar.APRIL, 25), Gender.MALE); final Person person12 = new Person(104L, "Lalkrishna", "Parmhansh", "Advani", DateTimeUtils.createDate(1910, Calendar.JANUARY, 01), Gender.MALE); final Person person13 = new Person(104L, "Shushma", "kumari", "Swaraj", DateTimeUtils.createDate(1943, Calendar.AUGUST, 10), Gender.FEMALE); final Person person14 = new Person(104L, "Arun", "raman", "jetly", DateTimeUtils.createDate(1942, Calendar.OCTOBER, 27), Gender.MALE); final Person person15 = new Person(104L, "Amit", "kumar", "shah", DateTimeUtils.createDate(1958, Calendar.DECEMBER, 21), Gender.MALE); final Person person16 = new Person(104L, "Shila", "kumari", "Dixit", DateTimeUtils.createDate(1927, Calendar.FEBRUARY, 15), Gender.FEMALE); Map<String, Object> userMap = new HashMap<String, Object>(); userMap.put("6", person6); userMap.put("7", person7); userMap.put("8", person8); userMap.put("9", person9); userMap.put("10", person10); userMap.put("11", person11); userMap.put("12", person12); userMap.put("13", person13); userMap.put("14", person14); userMap.put("15", person15); userMap.put("16", person16); region.putAll(userMap); if (cache != null) cache.getLogger().info("Gemfire Cache Client: Puts successfully done"); }
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetFirstDateOfWeekFR() { Date dateTest = DateUtil.getFirstDateOfWeek(java.sql.Date.valueOf("2013-04-20"), "fr"); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(15)); 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:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java
private String generateId() { int version = 1; StringBuffer docid = new StringBuffer(DATAIDPREFIX); docid.append(DOT);/*from w ww . j a va 2s. c o m*/ // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int time = 0; docid.append(calendar.get(Calendar.YEAR)); time = calendar.get(Calendar.DAY_OF_YEAR); if (time < 10) { docid.append("0"); docid.append("0"); docid.append(time); } else if (time < 100) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.HOUR_OF_DAY); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.MINUTE); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.SECOND); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } //sometimes this number is not unique, so we append a random number int random = (new Double(Math.random() * 100)).intValue(); docid.append(random); docid.append(DOT); docid.append(version); return docid.toString(); }
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetEndDateOfWeekFR() { Date dateTest = DateUtil.getEndDateOfWeek(java.sql.Date.valueOf("2013-04-20"), "fr"); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(21)); assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23)); assertThat(cal.get(Calendar.MINUTE), is(59)); assertThat(cal.get(Calendar.SECOND), is(59)); assertThat(cal.get(Calendar.MILLISECOND), is(999)); }
From source file:Time.java
/** * Return the 1-based month number of the month of this day. 1 = January, 2 = * February and so on.// w ww.j a v a 2 s . c o m * * @return Month number of this month */ public int getMonthNo() { // It is tempting to return getMonth() + 1 but this is conceptually // wrong, as Calendar month is an enumeration and the values are tags // only and can be anything. switch (getMonth()) { case Calendar.JANUARY: return 1; case Calendar.FEBRUARY: return 2; case Calendar.MARCH: return 3; case Calendar.APRIL: return 4; case Calendar.MAY: return 5; case Calendar.JUNE: return 6; case Calendar.JULY: return 7; case Calendar.AUGUST: return 8; case Calendar.SEPTEMBER: return 9; case Calendar.OCTOBER: return 10; case Calendar.NOVEMBER: return 11; case Calendar.DECEMBER: return 12; } // This will never happen return 0; }
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetFirstDateOfWeekFRBetween2Months() { Date dateTest = DateUtil.getFirstDateOfWeek(java.sql.Date.valueOf("2013-04-29"), "fr"); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2013)); assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(29)); 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: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')); }