List of usage examples for java.util Calendar JUNE
int JUNE
To view the source code for java.util Calendar JUNE.
Click Source Link
From source file:org.codekaizen.vtj.text.BpDateFormatTest.java
/** * DOCUMENT ME!// w ww . jav a 2 s. c om */ public void testIsoFormatting() { BpDateFormat fmt1 = null; String str1 = null; Calendar cal = Calendar.getInstance(); if (!cal.getTimeZone().getID().equals("America/Chicago")) { cal.setTimeZone(TimeZone.getTimeZone("America/Chicago")); cal.clear(); } cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44); cal.set(Calendar.MILLISECOND, 18); fmt1 = new BpDateFormat(BpDateFormat.ISO_DATE_ONLY, Locale.US); str1 = fmt1.format(cal.getTime()); assertEquals("2002-01-02", str1); fmt1 = new BpDateFormat(BpDateFormat.ISO_YEAR_WEEK, Locale.US); str1 = fmt1.format(cal.getTime()); assertEquals("2002-W01", str1); fmt1 = new BpDateFormat(BpDateFormat.ISO_TIME_ONLY, Locale.US); str1 = fmt1.format(cal.getTime()); assertEquals("T08:16:44", str1); fmt1 = new BpDateFormat(BpDateFormat.ISO_DATE_TIME, Locale.US); str1 = fmt1.format(cal.getTime()); assertEquals("2002-01-02T08:16:44.018-06:00", str1); cal.set(Calendar.MONTH, Calendar.JUNE); str1 = fmt1.format(cal.getTime()); assertEquals("2002-06-02T08:16:44.018-05:00", str1); cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44); cal.set(Calendar.MILLISECOND, 18); fmt1.setTimeZone(TimeZone.getTimeZone("UTC")); str1 = fmt1.format(cal.getTime()); assertEquals("2002-01-02T08:16:44.018Z", str1); cal.set(Calendar.MONTH, Calendar.JUNE); str1 = fmt1.format(cal.getTime()); assertEquals("2002-06-02T08:16:44.018Z", str1); cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tehran")); cal.set(2002, Calendar.JANUARY, 2, 8, 16, 44); cal.set(Calendar.MILLISECOND, 18); fmt1.setTimeZone(TimeZone.getTimeZone("Asia/Tehran")); str1 = fmt1.format(cal.getTime()); assertEquals("2002-01-02T08:16:44.018+03:30", str1); }
From source file:org.nuxeo.client.test.TestRepository.java
@Test public void itCanManagePermissions() { // ** CREATION **/ // First Check Document folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); ACP acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(2, acp.getAcls().get(0).getAces().size()); assertEquals("inherited", acp.getAcls().get(0).getName()); // Settings// w w w . j a v a2s . c o m GregorianCalendar begin = new GregorianCalendar(2015, Calendar.JUNE, 20, 12, 34, 56); GregorianCalendar end = new GregorianCalendar(2015, Calendar.JULY, 14, 12, 34, 56); ACE ace = new ACE(); ace.setUsername("user0"); ace.setPermission("Write"); ace.setCreator("Administrator"); ace.setBegin(begin); ace.setEnd(end); ace.setBlockInheritance(true); folder.addPermission(ace); // Final Check folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(4, acp.getAcls().get(0).getAces().size()); assertEquals("local", acp.getAcls().get(0).getName()); // ** DELETION **/ folder.removePermission("user0"); // Final Check folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(3, acp.getAcls().get(0).getAces().size()); assertEquals("local", acp.getAcls().get(0).getName()); }
From source file:edu.virginia.iath.snac.helpers.datastructures.SNACDate.java
/** * Gets the season dates for the given season and year. Since the season dates only change * +/- 2 days across most of time, we store a lookup table and calculate them directly. * Winter starts in December of the previous year and ends in the given year. * /*from w ww . ja v a 2s.c o m*/ * @param seasonStr Season to lookup (summer, spring, fall, autumn, winter) * @param year 4-digit year. * @return Array of Java Calendar objects containing the beginning and end dates of the season. */ private Calendar[] getSeasonDates(String seasonStr, int year) { Calendar[] seasonDates = new Calendar[2]; String season = seasonStr.toLowerCase().trim(); seasonDates[0] = Calendar.getInstance(); seasonDates[1] = Calendar.getInstance(); // Note: Java is WEIRD: 0 = JANUARY, 1 = FEBRUARY, ... if (season.equals("winter")) { seasonDates[0].set(year - 1, Calendar.DECEMBER, 21); seasonDates[1].set(year, Calendar.MARCH, 19); } else if (season.equals("spring")) { seasonDates[0].set(year, Calendar.MARCH, 20); seasonDates[1].set(year, Calendar.JUNE, 20); } else if (season.equals("fall") || season.equals("autumn")) { seasonDates[0].set(year, Calendar.SEPTEMBER, 22); seasonDates[1].set(year, Calendar.DECEMBER, 20); } else if (season.equals("summer")) { seasonDates[0].set(year, Calendar.JUNE, 21); seasonDates[1].set(year, Calendar.SEPTEMBER, 21); } return seasonDates; }
From source file:org.richfaces.component.CalendarComponentTest.java
public void testCalendarGetConvertedValue() throws Exception { UICalendar calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE); Calendar calendarObject = Calendar.getInstance(); calendarObject.clear();//from ww w .j a v a2s . com calendarObject.set(2007, Calendar.JUNE, 10); calendar.setCurrentDate(calendarObject.getTime()); calendar2.setDatePattern("dd/M/yy"); calendar.getConvertedValue(facesContext, "01/01/01"); calendar.getAsDate(new Date()); calendar.getAsLocale("ru_RU"); CalendarRendererBase renderer = new CalendarRenderer(); renderer.getConvertedValue(facesContext, calendar, new Date()); }
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 w w.ja v a 2s .co 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: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 ww . j av a 2 s . 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:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithCalendarArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Calendar calendarValue = config.calendarArray[0]; GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); assertEquals(3, config.calendarArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithCalendarList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Calendar calendarValue = config.calendarList.get(0); GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.JUNE, 14, 10, 10); assertEquals(Calendar.class, calendarValue.getClass().getSuperclass()); assertEquals(calendar.getTimeInMillis(), calendarValue.getTimeInMillis()); assertEquals(3, config.calendarList.size()); }
From source file:se.technipelago.weather.chart.Generator.java
public Map<String, Object> getWeatherData() { Map<String, Object> map = new HashMap<String, Object>(); // Put archived data into the map. setArchivedData(map);/*from w ww . j a v a2s .c o m*/ // Put current data into the map. setCurrentData(map); // Daily high/low values. // Calendar cal = Calendar.getInstance(); cal.setTime((Date) map.get("timestamp")); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cal.add(Calendar.DAY_OF_MONTH, -6); Date day7 = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, 6); Date day0 = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.MILLISECOND, -1); Date day1 = cal.getTime(); // High values. setHiLowData(day0, day1, "temp_out", true, map, "dailyHighTemp"); setHiLowData(day0, day1, "hum_out", true, map, "dailyHighHumidity"); setHiLowData(day0, day1, "wind_high", true, map, "dailyHighWind"); // Low values. setHiLowData(day0, day1, "temp_out", false, map, "dailyLowTemp"); setHiLowData(day0, day1, "hum_out", false, map, "dailyLowHumidity"); setHiLowData(day0, day1, "wind_avg", false, map, "dailyLowWind"); map.put("rain_today", getValue(day0, day1, "rain", SUM)); map.put("solar_hours", getSolarHours(new Timespan(day7, day1))); cal.set(Calendar.MONTH, Calendar.JUNE); cal.set(Calendar.DAY_OF_MONTH, 19); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date midsummer = cal.getTime(); cal.setTime(new Date()); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) { cal.add(Calendar.DAY_OF_MONTH, -1); } Date thursday = cal.getTime(); if (thursday.getTime() > midsummer.getTime()) { map.put("solligan", getSolarHours(new Timespan(midsummer, thursday))); map.put("solligan_time", thursday); } else { map.put("solligan", Float.valueOf(0)); } return map; }