List of usage examples for java.util Calendar JULY
int JULY
To view the source code for java.util Calendar JULY.
Click Source Link
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 ww . ja v a 2 s.c o m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:com.lloydtorres.stately.helpers.RaraHelper.java
/** * Determines if the current day in the EST/EDT timezone is a special day. * @return The special day mode/*from w w w .j av a2 s. com*/ */ public static int getSpecialDayStatus() { Calendar cal = new GregorianCalendar(); cal.setTimeZone(SparkleHelper.TIMEZONE_TORONTO); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); if (month == Calendar.JANUARY && day == 30) { return DAY_STATELY_BIRTHDAY; } else if (month == Calendar.JULY && day == 1) { return DAY_CANADA_DAY; } else if (month == Calendar.OCTOBER && day == 31) { return DAY_HALLOWEEN; } else if (month == Calendar.NOVEMBER && day == 13) { return DAY_NS_BIRTHDAY; } else { return DAY_NORMAL; } }
From source file:org.openanzo.test.client.TestDateTime.java
/** * Test the conversion of java.util.Calendar objects in the Anzo.java API into xsd:dateTime RDF literals with time zones. The test will add statements using * java.util.Calendar objects and verify that when those statements are retrieved, the expected lexical value, datatype, etc. are correct. * //from w w w .j a v a 2 s . c o m * @throws Exception */ public void testCalendarBecomesXsdDateTime() throws Exception { AnzoClient client = null; try { client = new AnzoClient(getDefaultClientConfiguration()); client.connect(); client.reset(loadStatements("initialize.trig"), null); ClientGraph graph = client.getReplicaGraph(GRAPH_URI); DatatypeFactory df = DatatypeFactory.newInstance(); // UTC Calendar cal = getCleanCalendar(); cal.set(2008, Calendar.JULY, 11, 16, 48, 32); XMLGregorianCalendar xmlcal = df.newXMLGregorianCalendar(2008, DatatypeConstants.JULY, 11, 16, 48, 32, DatatypeConstants.FIELD_UNDEFINED, 0); addAndRetrieveNativeLiteral(client, graph, cal, xmlcal, "2008-07-11T16:48:32Z", XMLSchema.DATETIME); // Time zone offset cal = getCleanCalendar(); cal.set(2008, Calendar.JULY, 11, 16, 48, 32); cal.setTimeZone(TimeZone.getTimeZone("GMT-09:00")); xmlcal = df.newXMLGregorianCalendar(2008, DatatypeConstants.JULY, 11, 16, 48, 32, DatatypeConstants.FIELD_UNDEFINED, -9 * 60); addAndRetrieveNativeLiteral(client, graph, cal, xmlcal, "2008-07-11T16:48:32-09:00", XMLSchema.DATETIME); // Fractional seconds cal = getCleanCalendar(); cal.set(2008, Calendar.JULY, 11, 16, 48, 32); cal.set(Calendar.MILLISECOND, 357); cal.setTimeZone(TimeZone.getTimeZone("GMT-03:00")); xmlcal = df.newXMLGregorianCalendar(2008, DatatypeConstants.JULY, 11, 16, 48, 32, 357, -3 * 60); addAndRetrieveNativeLiteral(client, graph, cal, xmlcal, "2008-07-11T16:48:32.357-03:00", XMLSchema.DATETIME); // A partially filled Calendar still ends up as a fully specified xsd:dateTime with the default values // used for unspecified fields (i.e. 0 for time fields, January for month, 1 for day of month, etc.) cal = getCleanCalendar(); cal.set(2008, Calendar.JULY, 11); cal.setTimeZone(TimeZone.getTimeZone("GMT-03:00")); xmlcal = df.newXMLGregorianCalendar(2008, DatatypeConstants.JULY, 11, 0, 0, 0, DatatypeConstants.FIELD_UNDEFINED, -3 * 60); addAndRetrieveNativeLiteral(client, graph, cal, xmlcal, "2008-07-11T00:00:00-03:00", XMLSchema.DATETIME); // Another partially filled Calendar. cal = getCleanCalendar(); cal.set(Calendar.YEAR, 2012); xmlcal = df.newXMLGregorianCalendar(2012, DatatypeConstants.JANUARY, 1, 0, 0, 0, DatatypeConstants.FIELD_UNDEFINED, 0); addAndRetrieveNativeLiteral(client, graph, cal, xmlcal, "2012-01-01T00:00:00Z", XMLSchema.DATETIME); } finally { if (client != null) { client.close(); } } }
From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java
public void shouldReturn1BusinessMonth20BusinessDaysWithoutTailingZeroes() { Calendar end = prepareCalendar(2011, Calendar.JULY, 31, 0, 0, 0, 0); // 31.07.2011 00:00:00.0 setEndTime(end.getTimeInMillis());/*w ww . j av a 2 s . c o m*/ Calendar start = (Calendar) end.clone(); start.set(Calendar.MONTH, Calendar.JUNE); start.set(Calendar.DAY_OF_MONTH, 10); setStartTime(start.getTimeInMillis()); expectedValue = messages.get("1BusinessMonth20BusinessDays"); }
From source file:com.evolveum.midpoint.report.BasicReportTest.java
private Calendar create_2013_07_01_00_00_Calendar() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.JULY); 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.gemstone.gemfire.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java
public static void verifyUpdatesInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);/*from w w w .j a v a2 s . c om*/ Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME); { Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3", DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE); Object value = region.get("3"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else if (value instanceof Person) { fail("VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance "); } } //TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the issue // CAS functionality is not working in following test case // step-1: Java client, Region.put("K", A); //Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing PdxInstance in cache and // PdxInstance generated from JSON (CAS request) does not match as their value's type are getting changed /* //verify update on key "1" { Object obj = region.get("1"); if (obj instanceof PdxInstance) { PdxInstance pi = (PdxInstance)obj; Person p1 = (Person)pi.getObject(); System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" + p1.toString()); }else { System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1 returned OBJECT: " + obj.toString()); } } */ //verify update on key "2" { Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama", DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE); Object value = region.get("2"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else { fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); } } //verify Deleted key "13" { Object obj = region.get("13"); assertEquals(obj, null); obj = region.get("14"); assertEquals(obj, null); obj = region.get("15"); assertEquals(obj, null); obj = region.get("16"); assertEquals(obj, null); } }
From source file:com.stasbar.knowyourself.Utils.java
/** * Generate arrays of short and long weekdays, starting from Sunday *///w ww .ja v a 2s .com private static void generateShortAndLongWeekdaysIfNeeded() { if (sShortWeekdays != null && sLongWeekdays != null && !localeHasChanged()) { // nothing to do return; } final Locale locale = Locale.getDefault(); final SimpleDateFormat shortFormat = new SimpleDateFormat(DATE_FORMAT_SHORT, locale); final SimpleDateFormat longFormat = new SimpleDateFormat(DATE_FORMAT_LONG, locale); sShortWeekdays = new String[DaysOfWeek.DAYS_IN_A_WEEK]; sLongWeekdays = new String[DaysOfWeek.DAYS_IN_A_WEEK]; // Create a date (2014/07/20) that is a Sunday final long aSunday = new GregorianCalendar(2014, Calendar.JULY, 20).getTimeInMillis(); for (int i = 0; i < DaysOfWeek.DAYS_IN_A_WEEK; i++) { final long dayMillis = aSunday + i * DateUtils.DAY_IN_MILLIS; sShortWeekdays[i] = shortFormat.format(new Date(dayMillis)); sLongWeekdays[i] = longFormat.format(new Date(dayMillis)); } // Track the Locale used to generate these weekdays sLocaleUsedForWeekdays = Locale.getDefault(); }
From source file:org.apache.geode.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java
public void verifyUpdatesInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);/* w w w.j av a 2s . c om*/ Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME); { Person expectedPerson = new Person(3L, "Nishka3", "Nilkanth3", "Patel3", DateTimeUtils.createDate(2009, Calendar.JULY, 31), Gender.FEMALE); Object value = region.get("3"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else if (value instanceof Person) { fail("VerifyUpdatesInClientCache, Get on key 3, Expected to get value of type PdxInstance "); } } // TODO: uncomment it once following issue encountered in put?op=CAS is fixed or document the // issue // CAS functionality is not working in following test case // step-1: Java client, Region.put("K", A); // Step-2: Rest CAS request for key "K" with data "@old" = A. CAS is failing as existing // PdxInstance in cache and // PdxInstance generated from JSON (CAS request) does not match as their value's type are // getting changed /* * //verify update on key "1" { Object obj = region.get("1"); if (obj instanceof PdxInstance) { * PdxInstance pi = (PdxInstance)obj; Person p1 = (Person)pi.getObject(); * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() : GET ON KEY=1" + * p1.toString()); }else { * System.out.println("Nilkanth1 : verifyUpdatesInClientCache() GET ON KEY=1 returned OBJECT: " * + obj.toString()); } } */ // verify update on key "2" { Person expectedPerson = new Person(501L, "Barack", "Hussein", "Obama", DateTimeUtils.createDate(1961, Calendar.APRIL, 8), Gender.MALE); Object value = region.get("2"); if (value instanceof PdxInstance) { PdxInstance pi3 = (PdxInstance) value; Person actualPerson = (Person) pi3.getObject(); assertEquals(actualPerson.getId(), expectedPerson.getId()); assertEquals(actualPerson.getFirstName(), expectedPerson.getFirstName()); assertEquals(actualPerson.getMiddleName(), expectedPerson.getMiddleName()); assertEquals(actualPerson.getLastName(), expectedPerson.getLastName()); assertEquals(actualPerson.getBirthDate(), expectedPerson.getBirthDate()); assertEquals(actualPerson.getGender(), expectedPerson.getGender()); } else { fail("VerifyUpdatesInClientCache, Get on key 2, Expected to get value of type PdxInstance "); } } // verify Deleted key "13" { Object obj = region.get("13"); assertEquals(obj, null); obj = region.get("14"); assertEquals(obj, null); obj = region.get("15"); assertEquals(obj, null); obj = region.get("16"); assertEquals(obj, null); } }
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 w ww . j ava2s .c o m throw new IllegalArgumentException("Invalid Month"); } }
From source file:com.android.deskclock.Utils.java
/** * Generate arrays of short and long weekdays, starting from Sunday *//*from w w w. ja v a 2 s . c om*/ private static void generateShortAndLongWeekdaysIfNeeded() { if (sShortWeekdays != null && sLongWeekdays != null && !localeHasChanged()) { // nothing to do return; } if (sShortWeekdays == null) { sShortWeekdays = new String[DaysOfWeek.DAYS_IN_A_WEEK]; } if (sLongWeekdays == null) { sLongWeekdays = new String[DaysOfWeek.DAYS_IN_A_WEEK]; } final SimpleDateFormat shortFormat = new SimpleDateFormat(DATE_FORMAT_SHORT); final SimpleDateFormat longFormat = new SimpleDateFormat(DATE_FORMAT_LONG); // Create a date (2014/07/20) that is a Sunday final long aSunday = new GregorianCalendar(2014, Calendar.JULY, 20).getTimeInMillis(); for (int i = 0; i < DaysOfWeek.DAYS_IN_A_WEEK; i++) { final long dayMillis = aSunday + i * DateUtils.DAY_IN_MILLIS; sShortWeekdays[i] = shortFormat.format(new Date(dayMillis)); sLongWeekdays[i] = longFormat.format(new Date(dayMillis)); } // Track the Locale used to generate these weekdays sLocaleUsedForWeekdays = Locale.getDefault(); }