List of usage examples for java.util Calendar MAY
int MAY
To view the source code for java.util Calendar MAY.
Click Source Link
From source file:org.jasig.schedassist.impl.relationship.advising.TermCalculator.java
/** * Calculate the term number for the specified date time (as a {@link Calendar}). * This uses a rough formula to determine Fall/Spring/Summer semesters: <pre>/*from w w w.j a va2 s. co m*/ if the month is between January and May (inclusive), the term is Spring. if the month is between June and August (inclusive), the term is Summer. if the month is between September and December (inclusive), the term is Fall. </pre> * * This is only approximate. * * @param calendar * @return */ public static String calculateTerm(final Calendar calendar) { StringBuilder term = new StringBuilder(); int month = calendar.get(Calendar.MONTH); String monthDigit; if (month >= Calendar.JANUARY && month <= Calendar.MAY) { monthDigit = "4"; } else if (month >= Calendar.JUNE && month <= Calendar.AUGUST) { monthDigit = "6"; } else { monthDigit = "2"; } int year = calendar.get(Calendar.YEAR); if ("2".equals(monthDigit)) { // increment year by one for fall semester year++; } String centuryDigit = "0"; if (year >= 2000) { centuryDigit = "1"; } int twoDigitYear = year % 100; String yearDigit = StringUtils.leftPad(Integer.toString(twoDigitYear), 2, "0"); term.append(centuryDigit); term.append(yearDigit); term.append(monthDigit); return term.toString(); }
From source file:javaeetutorial.web.websocketbot.BotBean.java
public String respond(String msg) { String response = null;//w w w. j ava2 s . co m String nbaresults; List<NBA> list = null; NBADecoder nbadecoder; /* Remove question marks */ msg = msg.toLowerCase().replaceAll("\\?", ""); if (msg.contains("how are you")) { response = "I'm doing great, thank you!"; } else if (msg.contains("how old are you")) { Calendar dukesBirthday = new GregorianCalendar(1995, Calendar.MAY, 23); Calendar now = GregorianCalendar.getInstance(); int dukesAge = now.get(Calendar.YEAR) - dukesBirthday.get(Calendar.YEAR); response = String.format("I'm %d years old.", dukesAge); } else if (msg.contains("when is your birthday")) { response = "My birthday is on May 23rd. Thanks for asking!"; } else if (msg.contains("") | msg.contains("?")) { String nbaUri = "http://op.juhe.cn/onebox/basketball/team?key=0564267c0eb0ed260583698c8ea0e605&dtype=json&team="; String divUri = "http://ltpapi.voicecloud.cn/analysis/?api_key=41g4M3f3b6C7L387G0c6XcEOcY5QwaMCWDRoYhGa&pattern=ws&&pattern=dp&format=plain&text="; String divresults = get(msg, divUri); String[] phrase = divresults.split("\\s"); for (int j = 0; j < phrase.length; j++) { nbaresults = get(phrase[j], nbaUri); nbadecoder = new NBADecoder(); list = nbadecoder.decode(nbaresults); if (list != null) { response += "?" + phrase[j]; for (NBA nba : list) { response += "\n" + nba.getPlaydate() + nba.getPlaytime() + ",?" + nba.getName1() + "VS" + "?" + nba.getName2() + "" + nba.getScore() + "" + nba.getLink(); response += "\n"; } } else { response = "???"; } } } else { response = "Sorry, I did not understand what you said. "; response += "You can ask me how I'm doing today; how old I am; or "; response += "what my favorite color is."; } try { Thread.sleep(1200); } catch (InterruptedException ex) { } return response; }
From source file:org.lieuofs.commune.biz.RechercheCommuneTest.java
@Test public void rechercheValideAUneDateDonnee() { // La commune Collina d'Oro(5236) a absorb la commune Carabietta(5169) le 01.04.2012 CommuneCritere critere = new CommuneCritere(); Calendar cal = Calendar.getInstance(); cal.set(2012, Calendar.MAY, 11); critere.setDateValidite(cal.getTime()); List<ICommuneSuisse> communes = gestionnaire.rechercher(critere); assertThat(extractProperty("numeroOFS").from(communes)).contains(5236).doesNotContain(5169); }
From source file:ch.cyberduck.core.ftp.parser.NetwareFTPEntryParserTest.java
/** * #1996//from w w w . ja v a 2s. com */ @Test public void testDateYearParser() { FTPFile parsed; parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 24038 May 05 17:57 CIMSscheduler_log_May02_4.txt"); assertNotNull(parsed); assertEquals(parsed.getName(), "CIMSscheduler_log_May02_4.txt"); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals("wtubbs", parsed.getUser()); assertEquals(24038, parsed.getSize()); assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(5, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 9965 May 01 18:15 CIMSscheduler_log_May01.txt"); assertNotNull(parsed); assertEquals(parsed.getName(), "CIMSscheduler_log_May01.txt"); assertEquals(FTPFile.FILE_TYPE, parsed.getType()); assertEquals("wtubbs", parsed.getUser()); assertEquals(9965, parsed.getSize()); assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); }
From source file:is.idega.idegaweb.egov.gumbo.licenses.SetDraganotveidiValidPeriod.java
private Interval findNearestPeriod(Calendar now) { final int year; if (now.get(Calendar.MONTH) > Calendar.AUGUST) { year = now.get(Calendar.YEAR) + 1; } else {//from w ww. j av a 2 s.co m year = now.get(Calendar.YEAR); } final Calendar mayStart = Calendar.getInstance(); mayStart.set(year, Calendar.MAY, 1, 0, 0, 0); final Calendar augEnd = Calendar.getInstance(); augEnd.set(year, Calendar.AUGUST, 31, 0, 0, 0); return new Interval(mayStart.getTime(), augEnd.getTime()); }
From source file:net.orpiske.dcd.collector.dataset.impl.MBoxDataSetTest.java
@Test public void testOneDigitDateWithTZ() { Data data = dataList.get(0);/* w w w .j av a 2 s . c om*/ Date date = data.getDate(); Calendar cal = Calendar.getInstance(); cal.setTime(date); assertEquals("The year is incorrect", 2013, cal.get(Calendar.YEAR)); assertEquals("The month is incorrect", Calendar.MAY, cal.get(Calendar.MONTH)); assertEquals("The day is incorrect", 2, cal.get(Calendar.DAY_OF_MONTH)); }
From source file:one.GanttDemo1.java
/** * Creates a sample dataset for a Gantt chart. * * @return The dataset./*from ww w. j a v a 2 s . com*/ */ public static IntervalCategoryDataset createDataset() { final TaskSeries s1 = new TaskSeries("Scheduled"); s1.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s1.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s1.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)))); s1.add(new Task("Design Phase", new SimpleTimePeriod(date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)))); s1.add(new Task("Design Signoff", new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)))); s1.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)))); s1.add(new Task("Design Review", new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)))); s1.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)))); s1.add(new Task("Beta Implementation", new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s1.add(new Task("Testing", new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)))); s1.add(new Task("Final Implementation", new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)))); s1.add(new Task("Signoff", new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)))); s1.add(new Task("Database set up", new SimpleTimePeriod(date(15, Calendar.OCTOBER, 2001), date(30, Calendar.OCTOBER, 2001)))); final TaskSeries s2 = new TaskSeries("Actual"); s2.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s2.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s2.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(15, Calendar.MAY, 2001)))); s2.add(new Task("Design Phase", new SimpleTimePeriod(date(15, Calendar.MAY, 2001), date(17, Calendar.JUNE, 2001)))); s2.add(new Task("Design Signoff", new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), date(30, Calendar.JUNE, 2001)))); s2.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(1, Calendar.JULY, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Design Review", new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), date(22, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(25, Calendar.SEPTEMBER, 2001), date(27, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Beta Implementation", new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), date(30, Calendar.OCTOBER, 2001)))); s2.add(new Task("Testing", new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), date(17, Calendar.NOVEMBER, 2001)))); s2.add(new Task("Final Implementation", new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), date(5, Calendar.DECEMBER, 2001)))); s2.add(new Task("Signoff", new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), date(11, Calendar.DECEMBER, 2001)))); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); collection.add(s2); return collection; }
From source file:de.forsthaus.backend.dao.impl.ChartDataDAOImpl.java
@Override public List<ChartData> getChartDataForCustomer(long kunId) { List<ChartData> result = new ArrayList<ChartData>(); if (kunId == 20) { Calendar calendar = new GregorianCalendar(); calendar.set(2009, Calendar.JANUARY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30))); calendar.set(2009, Calendar.FEBRUARY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(450.30))); calendar.set(2009, Calendar.MARCH, 15, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(820.10))); calendar.set(2009, Calendar.APRIL, 20, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(654.00))); calendar.set(2009, Calendar.MAY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30))); calendar.set(2009, Calendar.JUNE, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(520.30))); calendar.set(2009, Calendar.JULY, 22, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30))); calendar.set(2009, Calendar.AUGUST, 13, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(20.30))); calendar.set(2009, Calendar.SEPTEMBER, 6, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(480.30))); calendar.set(2009, Calendar.OCTOBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(520.30))); calendar.set(2009, Calendar.NOVEMBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.70))); calendar.set(2009, Calendar.DECEMBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(1220.90))); } else if (kunId == 21) { Calendar calendar = new GregorianCalendar(); calendar.set(2009, Calendar.JANUARY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30))); calendar.set(2009, Calendar.FEBRUARY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(450.30))); calendar.set(2009, Calendar.MARCH, 15, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.10))); calendar.set(2009, Calendar.APRIL, 20, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(154.00))); calendar.set(2009, Calendar.MAY, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30))); calendar.set(2009, Calendar.JUNE, 2, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.30))); calendar.set(2009, Calendar.JULY, 22, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(920.30))); calendar.set(2009, Calendar.AUGUST, 13, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30))); calendar.set(2009, Calendar.SEPTEMBER, 6, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(680.30))); calendar.set(2009, Calendar.OCTOBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(580.30))); calendar.set(2009, Calendar.NOVEMBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(820.70))); calendar.set(2009, Calendar.DECEMBER, 26, 0, 0, 0); result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(220.90))); }//ww w .ja v a 2 s . c o m return result; }
From source file:net.orpiske.dcd.collector.dataset.impl.MBoxDataSetTest.java
@Test public void testTwoDigitDateWithTZ() { Data data = dataList.get(1);//from w w w . ja v a2 s . c o m Date date = data.getDate(); Calendar cal = Calendar.getInstance(); cal.setTime(date); assertEquals("The year is incorrect", 2013, cal.get(Calendar.YEAR)); assertEquals("The month is incorrect", Calendar.MAY, cal.get(Calendar.MONTH)); assertEquals("The day is incorrect", 20, cal.get(Calendar.DAY_OF_MONTH)); }
From source file:com.evolveum.midpoint.repo.sql.CleanupTest.java
License:asdf
private Calendar create_2013_07_12_12_00_Calendar() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.MAY); calendar.set(Calendar.DAY_OF_MONTH, 7); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; }