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:org.techytax.util.DateHelper.java
public static Date getLastDayOfFirstMonthOfNextQuarter(Date date) { int month = getMonth(date); int year = getYear(date); Calendar cal = new GregorianCalendar(); cal.set(Calendar.YEAR, year); Date lastDay = null;//from www . j a va 2s . c o m switch (month) { case 0: case 1: case 2: case 3: cal.set(Calendar.MONTH, Calendar.APRIL); cal.set(Calendar.DAY_OF_MONTH, 30); lastDay = cal.getTime(); break; case 4: case 5: case 6: cal.set(Calendar.MONTH, Calendar.JULY); cal.set(Calendar.DAY_OF_MONTH, 31); lastDay = cal.getTime(); break; case 7: case 8: case 9: cal.set(Calendar.MONTH, Calendar.OCTOBER); cal.set(Calendar.DAY_OF_MONTH, 31); lastDay = cal.getTime(); break; case 10: case 11: cal.add(Calendar.YEAR, 1); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 31); lastDay = cal.getTime(); break; default: break; } return lastDay; }
From source file:netmason.support.graphics.GanttDisplay.java
/** * Creates a sample dataset for a Gantt chart, using sub-tasks. In general, * you won't hard-code the dataset in this way - it's done here so that the * demo is self-contained./*w w w . j av a2s . c om*/ * * @return The dataset. */ private IntervalCategoryDataset createSampleDataset() { final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)); t1.setPercentComplete(1.00); s1.add(t1); final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)); t2.setPercentComplete(1.00); s1.add(t2); // here is a task split into two subtasks... final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)); final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001), date(25, Calendar.APRIL, 2001)); st31.setPercentComplete(1.0); final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001)); st32.setPercentComplete(1.0); t3.addSubtask(st31); t3.addSubtask(st32); s1.add(t3); // and another... final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001)); st41.setPercentComplete(1.0); final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001)); st42.setPercentComplete(1.0); final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); st43.setPercentComplete(0.50); t4.addSubtask(st41); t4.addSubtask(st42); t4.addSubtask(st43); s1.add(t4); final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)); s1.add(t5); final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)); t6.setPercentComplete(0.60); s1.add(t6); final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)); t7.setPercentComplete(0.0); s1.add(t7); final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)); t8.setPercentComplete(0.0); s1.add(t8); final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)); t9.setPercentComplete(0.0); s1.add(t9); final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)); t10.setPercentComplete(0.0); s1.add(t10); final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)); t11.setPercentComplete(0.0); s1.add(t11); final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)); t12.setPercentComplete(0.0); s1.add(t12); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:org.jfree.chart.demo.GanttDemo2.java
/** * Creates a sample dataset for a Gantt chart, using sub-tasks. In general, you won't * hard-code the dataset in this way - it's done here so that the demo is self-contained. * * @return The dataset./*from w w w . j a v a 2 s. c om*/ */ private IntervalCategoryDataset createSampleDataset() { final TaskSeries s1 = new TaskSeries("Scheduled"); final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)); t1.setPercentComplete(1.00); s1.add(t1); final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)); t2.setPercentComplete(1.00); s1.add(t2); // here is a task split into two subtasks... final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)); final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001), date(25, Calendar.APRIL, 2001)); st31.setPercentComplete(1.0); final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001)); st32.setPercentComplete(1.0); t3.addSubtask(st31); t3.addSubtask(st32); s1.add(t3); // and another... final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001)); st41.setPercentComplete(1.0); final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001)); st42.setPercentComplete(1.0); final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)); st43.setPercentComplete(0.50); t4.addSubtask(st41); t4.addSubtask(st42); t4.addSubtask(st43); s1.add(t4); final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)); s1.add(t5); final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)); t6.setPercentComplete(0.60); s1.add(t6); final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)); t7.setPercentComplete(0.0); s1.add(t7); final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)); t8.setPercentComplete(0.0); s1.add(t8); final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)); t9.setPercentComplete(0.0); s1.add(t9); final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)); t10.setPercentComplete(0.0); s1.add(t10); final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)); t11.setPercentComplete(0.0); s1.add(t11); final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)); t12.setPercentComplete(0.0); s1.add(t12); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:com.xing.api.JsonSerializationTest.java
private static void assertCompanies(XingUser user) throws Exception { Company first = buildPrimaryCompany(); Company second = new Company().id("24_abcdef").name("Ninja Ltd.").title("DevOps").tag("NINJA") .url("http://www.ninja-ltd.co.uk").beginDate(new SafeCalendar(2009, Calendar.APRIL)) .endDate(new SafeCalendar(2010, Calendar.JULY)) .industries(/* ww w . j av a2s . c o m*/ Collections.singletonList(new Industry(220800, "Athletes, organisers and associations"))) .formOfEmployment(FormOfEmployment.OWNER) .discipline(new Discipline("12_05e01e", "IT_AND_SOFTWARE_DEVELOPMENT")); Company third = new Company().id("45_abcdef").title("Wiss. Mitarbeiter").tag("OFFIS") .url("http://www.uni.de").beginDate(new SafeCalendar(2007)).endDate(new SafeCalendar(2008)) .industries(Collections.singletonList(new Industry(20400, "Fashion and textiles"))) .formOfEmployment(FormOfEmployment.PART_TIME_EMPLOYEE) .discipline(new Discipline("9_5e231a", "TEACHING_R_AND_D")); Company forth = new Company().id("176_abcdef").title("TEST NINJA").companySize(CompanySize.SIZE_201_500) .tag("TESTCOMPANY").careerLevel(CareerLevel.ENTRY_LEVEL) .beginDate(new SafeCalendar(1998, Calendar.DECEMBER)).endDate(new SafeCalendar(1999, Calendar.MAY)) .industries( Collections.singletonList(new Industry(220800, "Athletes, organisers and associations"))) .formOfEmployment(FormOfEmployment.INTERN); assertThat(user.professionalExperience().companies()).containsExactly(first, second, third, forth); }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSHistoryFileToSQL.java
private Date getSystemReleaseDate(String releaseId) throws Exception { String sYear = releaseId.substring(0, 4); int year = new Integer(sYear).intValue(); String sMonth = releaseId.substring(4); int mon = 0;/*from w w w.j a v a 2 s . c o m*/ Calendar cal = Calendar.getInstance(); if ("AA".equalsIgnoreCase(sMonth)) { mon = Calendar.JANUARY; } else if ("AB".equalsIgnoreCase(sMonth)) { mon = Calendar.APRIL; } else if ("AC".equalsIgnoreCase(sMonth)) { mon = Calendar.JULY; } else if ("AD".equalsIgnoreCase(sMonth)) { mon = Calendar.OCTOBER; } else { try { int i = Integer.parseInt(sMonth); switch (i) { case 1: mon = Calendar.JANUARY; break; case 2: mon = Calendar.FEBRUARY; break; case 3: mon = Calendar.MARCH; break; case 4: mon = Calendar.APRIL; break; case 5: mon = Calendar.MAY; break; case 6: mon = Calendar.JUNE; break; case 7: mon = Calendar.JULY; break; case 8: mon = Calendar.AUGUST; break; case 9: mon = Calendar.SEPTEMBER; break; case 10: mon = Calendar.OCTOBER; break; case 11: mon = Calendar.NOVEMBER; break; case 12: mon = Calendar.DECEMBER; break; default: throw new Exception("Release ID is not in required format: " + sMonth); } } catch (NumberFormatException e) { throw new Exception("Release ID is not in required format." + sMonth); } } cal.set(year, mon, 01, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); return new Date(cal.getTimeInMillis()); }
From source file:ISO8601DateTimeFormat.java
/** * Write century, year, and months./* w w w . j av a 2s. co m*/ * @param sbuf The buffer to append the string. */ protected final void writeCCYYMM(StringBuffer sbuf) { int year = calendar.get(Calendar.YEAR); appendInt(sbuf, year, 4); String month; switch (calendar.get(Calendar.MONTH)) { case Calendar.JANUARY: month = "-01-"; break; case Calendar.FEBRUARY: month = "-02-"; break; case Calendar.MARCH: month = "-03-"; break; case Calendar.APRIL: month = "-04-"; break; case Calendar.MAY: month = "-05-"; break; case Calendar.JUNE: month = "-06-"; break; case Calendar.JULY: month = "-07-"; break; case Calendar.AUGUST: month = "-08-"; break; case Calendar.SEPTEMBER: month = "-09-"; break; case Calendar.OCTOBER: month = "-10-"; break; case Calendar.NOVEMBER: month = "-11-"; break; case Calendar.DECEMBER: month = "-12-"; break; default: month = "-NA-"; break; } sbuf.append(month); int day = calendar.get(Calendar.DAY_OF_MONTH); appendInt(sbuf, day, 2); }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting month long description * //from ww w . ja v a2s. c o m * @param mthNum * @return */ public static String getMonthLongDesc(int mthNum) { String mthLongDesc; switch (mthNum) { case Calendar.JANUARY: { mthLongDesc = DateTimeConstants.JANUARY; break; } case Calendar.FEBRUARY: { mthLongDesc = DateTimeConstants.FEBRUARY; break; } case Calendar.MARCH: { mthLongDesc = DateTimeConstants.MARCH; break; } case Calendar.APRIL: { mthLongDesc = DateTimeConstants.APRIL; break; } case Calendar.MAY: { mthLongDesc = DateTimeConstants.MAY; break; } case Calendar.JUNE: { mthLongDesc = DateTimeConstants.JUNE; break; } case Calendar.JULY: { mthLongDesc = DateTimeConstants.JULY; break; } case Calendar.AUGUST: { mthLongDesc = DateTimeConstants.AUGUST; break; } case Calendar.SEPTEMBER: { mthLongDesc = DateTimeConstants.SEPTEMBER; break; } case Calendar.OCTOBER: { mthLongDesc = DateTimeConstants.OCTOBER; break; } case Calendar.NOVEMBER: { mthLongDesc = DateTimeConstants.NOVEMBER; break; } case Calendar.DECEMBER: { mthLongDesc = DateTimeConstants.DECEMBER; break; } default: { mthLongDesc = ""; break; } } return mthLongDesc; }
From source file:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testAddDays() { Calendar calend = Calendar.getInstance(); calend.set(Calendar.DATE, 27); calend.set(Calendar.MONTH, Calendar.JUNE); calend.set(Calendar.YEAR, 2012); calend.setTimeZone(TimeZone.getTimeZone("GMT+01")); assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.WEDNESDAY)); DateUtil.addDaysExceptWeekEnds(calend, 2); assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.FRIDAY)); assertThat(calend.get(Calendar.DATE), is(29)); assertThat(calend.get(Calendar.MONTH), is(Calendar.JUNE)); assertThat(calend.get(Calendar.YEAR), is(2012)); calend = Calendar.getInstance(); calend.set(Calendar.DATE, 27); calend.set(Calendar.MONTH, Calendar.JUNE); calend.set(Calendar.YEAR, 2012); calend.setTimeZone(TimeZone.getTimeZone("GMT+01")); assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.WEDNESDAY)); DateUtil.addDaysExceptWeekEnds(calend, 4); assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.TUESDAY)); assertThat(calend.get(Calendar.DATE), is(3)); assertThat(calend.get(Calendar.MONTH), is(Calendar.JULY)); assertThat(calend.get(Calendar.YEAR), is(2012)); }
From source file:ch.ralscha.extdirectspring.controller.RouterControllerSimpleNamedTest.java
@Test public void testReturnsObject() { Map<String, Object> params = new LinkedHashMap<String, Object>(); params.put("d", 7.34); FormInfo info = (FormInfo) ControllerUtil.sendAndReceiveNamed(mockMvc, "remoteProviderSimpleNamed", "method5", FormInfo.class, params); assertThat(info.getBack()).isEqualTo(7.34); assertThat(info.isAdmin()).isEqualTo(Boolean.FALSE); assertThat(info.getAge()).isEqualTo(32); assertThat(info.getName()).isEqualTo("John"); assertThat(info.getSalary()).isEqualTo(new BigDecimal("8720.2")); assertThat(info.getBirthday()).isEqualTo(new GregorianCalendar(1986, Calendar.JULY, 22).getTime()); }
From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java
/** * http://trac.cyberduck.ch/ticket/143/*from w w w . java 2 s. c om*/ */ @Test public void testLeadingWhitespace() { FTPFileEntryParser parser = new FTPParserSelector().getParser("UNIX"); FTPFile parsed; parsed = parser.parseFTPEntry("-rw-r--r-- 1 20708 205 3553312 Feb 18 2005 D3I0_515.fmr"); assertNotNull(parsed); assertTrue(parsed.isFile()); assertEquals("D3I0_515.fmr", parsed.getName()); assertEquals("20708", parsed.getUser()); assertEquals("205", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.FEBRUARY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(18, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2005, parsed.getTimestamp().get(Calendar.YEAR)); parsed = parser.parseFTPEntry("drwxr-sr-x 14 17037 209 4096 Oct 6 2000 v3r7"); assertNotNull(parsed); assertTrue(parsed.isDirectory()); assertEquals("v3r7", parsed.getName()); assertEquals("17037", parsed.getUser()); assertEquals("209", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(6, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2000, parsed.getTimestamp().get(Calendar.YEAR)); // #2895 parsed = parser.parseFTPEntry("-rwx------ 1 user group 38635 Jul 13 2006 users.xml"); assertNotNull(parsed); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals("users.xml", parsed.getName()); assertEquals("user", parsed.getUser()); assertEquals("group", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.JULY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(13, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2006, parsed.getTimestamp().get(Calendar.YEAR)); }