List of usage examples for java.util Calendar AUGUST
int AUGUST
To view the source code for java.util Calendar AUGUST.
Click Source Link
From source file:org.teavm.flavour.json.test.SerializerTest.java
@Test public void writesFormattedDate() { Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.setTimeInMillis(0);//from ww w .j av a 2s . c o m calendar.set(Calendar.YEAR, 2015); calendar.set(Calendar.MONTH, Calendar.AUGUST); calendar.set(Calendar.DATE, 2); calendar.set(Calendar.HOUR_OF_DAY, 16); calendar.set(Calendar.MINUTE, 25); calendar.set(Calendar.SECOND, 35); Date date = calendar.getTime(); DateFormats formats = new DateFormats(); formats.numeric = date; formats.textual = date; JsonNode node = JSONRunner.serialize(formats); assertTrue("Numeric date is a number", node.get("numeric").isNumber()); assertEquals(date.getTime(), node.get("numeric").asDouble(), 0.1); assertTrue("Textual date is a string", node.get("textual").isTextual()); assertEquals("2015-08-02 16:25:35 Z", node.get("textual").asText()); }
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; }//from w ww .ja va2 s . co 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: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://from w w w . j a v a 2 s . c om throw new IllegalArgumentException("Invalid Month"); } }
From source file:org.jfree.data.time.WeekTest.java
/** * A test for a problem in constructing a new Week instance. *///from ww w . j a v a 2s. c om @Test public void testConstructor() { Locale savedLocale = Locale.getDefault(); TimeZone savedZone = TimeZone.getDefault(); Locale.setDefault(new Locale("da", "DK")); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen")); GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); // first day of week is monday assertEquals(Calendar.MONDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); Date t = cal.getTime(); Week w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(34, w.getWeek()); Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("US/Detroit")); cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); // first day of week is Sunday assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); t = cal.getTime(); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(35, w.getWeek()); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen"), new Locale("da", "DK")); assertEquals(34, w.getWeek()); Locale.setDefault(savedLocale); TimeZone.setDefault(savedZone); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithDateArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Date dateValue = config.dateArray[0]; GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithDateList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Date dateValue = config.dateList.get(0); GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateList.size()); }
From source file:com.evolveum.midpoint.report.BasicReportTest.java
private Calendar create_2013_08_01_00_00_Calendar() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.AUGUST); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }
From source file:com.tr4android.support.extension.picker.date.SimpleMonthView.java
private 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: return (year % 4 == 0) ? 29 : 28; default:/*from ww w . j a va 2 s .co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * ?//from www . ja va 2s .c om * * @param date * @return */ public static Date[] getSeasonDate(Date date) { Date[] season = new Date[3]; Calendar c = Calendar.getInstance(); c.setTime(date); int nSeason = getSeason(date); if (nSeason == 1) {// c.set(Calendar.MONTH, Calendar.JANUARY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.FEBRUARY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.MARCH); season[2] = c.getTime(); } else if (nSeason == 2) {// c.set(Calendar.MONTH, Calendar.APRIL); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.MAY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.JUNE); season[2] = c.getTime(); } else if (nSeason == 3) {// c.set(Calendar.MONTH, Calendar.JULY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.AUGUST); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.SEPTEMBER); season[2] = c.getTime(); } else if (nSeason == 4) {// c.set(Calendar.MONTH, Calendar.OCTOBER); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.NOVEMBER); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.DECEMBER); season[2] = c.getTime(); } return season; }