List of usage examples for java.util Calendar MARCH
int MARCH
To view the source code for java.util Calendar MARCH.
Click Source Link
From source file:Main.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: return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28; default://from www.j a v a2 s . c o m throw new IllegalArgumentException("Invalid Month"); } }
From source file:Main.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: return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29; default:/*from www . j a va2s. co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java
/** * {@inheritDoc}// w ww. j av a 2s . co m */ @Override public Halbjahr getHalbjahr(final Calendar currentDate) { if (currentDate.get(Calendar.MONTH) >= Calendar.MARCH && currentDate.get(Calendar.MONTH) < Calendar.AUGUST) { return Halbjahr.Beide_Halbjahre; } else { return Halbjahr.Erstes_Halbjahr; } }
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))); }//from w w w .j a v a 2s . com return result; }
From source file:com.cemeterylistingswebtest.test.services.adminRegisterListingServiceTest.java
@Test public void Test() { deadRepo = ctx.getBean(RequiresApprovalDeceasedListingRepository.class); adserv = ctx.getBean(AdminRegisterListingService.class); subRepo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); //Initialise date Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, Calendar.MARCH); calendar.set(Calendar.DATE, 5); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); //Initialise date Calendar calendar2 = Calendar.getInstance(); calendar2.set(Calendar.YEAR, 2014); calendar2.set(Calendar.MONTH, Calendar.JUNE); calendar2.set(Calendar.DATE, 20); java.sql.Date validDate = new java.sql.Date(calendar2.getTime().getTime()); //Initialise user role UserRole userRole = new UserRole.Builder().setLevel(2).build(); Subscriber newSub = new Subscriber.Builder().setEmail("jackieChan@yahoo.com").setFirstName("jackie") .setSurname("Chan").setPwd("whaa").setUsername("jChan").setSubscriptionDate(javaSqlDate) .setUserRoleID(userRole).setValidUntil(validDate).build(); subRepo.save(newSub);/*from w w w .ja v a2 s. com*/ subID = newSub.getSubscriberID(); long listId = adserv.registerDeceasedListingReturn("zaakir", "arendse", "maiden", "male", "date1", "date2", "blah", "27", "url", "zaakir27", "0474754", subID); Assert.assertFalse(deadRepo.findAll().isEmpty()); subRepo.delete(newSub); deadRepo.delete(listId); }
From source file:ejava.projects.edmv.xml.EDmvBindingTest.java
public void testCalendar() throws Exception { log.info("*** testCalendar ***"); DatatypeFactory dataFactory = DatatypeFactory.newInstance(); log.info("DataTypeFactory=" + dataFactory); XMLGregorianCalendar cal = dataFactory.newXMLGregorianCalendar(); log.info("XMLGregorianCalendar=" + cal.getClass()); cal.setMonth(GregorianCalendar.MARCH); String xml = cal.toXMLFormat(); log.debug("cal=" + xml); dataFactory.newXMLGregorianCalendar(xml); cal.setTimezone(0);/*from w w w .j ava 2 s . c om*/ Calendar jCal = Calendar.getInstance(); jCal.clear(); jCal.set(Calendar.MONTH, Calendar.MARCH); DateFormat df = DateFormat.getDateInstance(); String dfString = df.format(jCal.getTime()); log.debug("calendar=" + dfString); String format = "--01"; try { XMLGregorianCalendar xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); format = "--01--"; xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); } catch (Exception ex) { log.error("failed to parse:" + format); fail("failed to parse:" + format); } }
From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java
@Test public void testParseTimestamp() { FTPFileEntryParser parser = new FTPParserSelector().getParser("UNIX"); FTPFile parsed;// w w w.ja v a 2s. c om parsed = parser .parseFTPEntry("drw-rw-rw- 1 user ftp 0 DEC 11 20:56 ADMIN_Documentation"); assertNotNull(parsed); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(11, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(20, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY)); assertEquals(56, parsed.getTimestamp().get(Calendar.MINUTE)); parsed = parser.parseFTPEntry("drwxr-xr-x 3 ftp ftp 512 Mar 15 2004 doc"); assertNotNull(parsed); assertNotNull(parsed.getTimestamp()); assertEquals(2004, parsed.getTimestamp().get(Calendar.YEAR)); assertEquals(Calendar.MARCH, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); parsed = parser.parseFTPEntry("drwxrwxr-x 2 ftp ftp 512 Oct 23 2007 aurox"); assertNotNull(parsed); assertNotNull(parsed.getTimestamp()); assertEquals(2007, parsed.getTimestamp().get(Calendar.YEAR)); assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(23, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); }
From source file:com.cemeterylistingswebtest.test.services.AdminPublishedListingServiceTest.java
@Test public void hello() { pubRepo = ctx.getBean(PublishedDeceasedListingRepository.class); updatePubserv = ctx.getBean(AdminUpdatePublishedListingService.class); subRepo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); //Initialise date Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, Calendar.MARCH); calendar.set(Calendar.DATE, 5); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); //Initialise date Calendar calendar2 = Calendar.getInstance(); calendar2.set(Calendar.YEAR, 2014); calendar2.set(Calendar.MONTH, Calendar.JUNE); calendar2.set(Calendar.DATE, 20); java.sql.Date validDate = new java.sql.Date(calendar2.getTime().getTime()); //Initialise user role UserRole userRole = new UserRole.Builder().setLevel(2).build(); Subscriber newSub = new Subscriber.Builder().setEmail("jackieChan@yahoo.com").setFirstName("jackie") .setSurname("Chan").setPwd("whaa").setUsername("jChan").setSubscriptionDate(javaSqlDate) .setUserRoleID(userRole).setValidUntil(validDate).build(); subRepo.save(newSub);//from w ww. j av a 2s .c o m subID = newSub.getSubscriberID(); PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Dean") .setSurname("Winchester") .setGender("Male").setDateOfBirth("27/07/1985").setDateOfDeath("14/10/2014") .setGraveInscription("will probably come back").setGraveNumber("2474") .setImageOfBurialSite("/images/004.jpg").setLastKnownContactName("sam") .setLastKnownContactNumber("07255718927") .setSubscriberSubmitID(subID).build(); pubRepo.save(newListing); listingId = newListing.getPublishedListingID(); PublishedDeceasedListing updateListing = new PublishedDeceasedListing.Builder() .PublishedDeceasedListing(newListing).setFirstName("Sam").setSurname(newListing.getSurname()) .setMaidenName(newListing.getMaidenName()).setGender(newListing.getGender()) .setDateOfBirth(newListing.getDateOfBirth()).setDateOfDeath(newListing.getDateOfDeath()) .setGraveInscription(newListing.getGraveInscription()).setGraveNumber(newListing.getGraveNumber()) .setLastKnownContactName(newListing.getLastKnownContactName()) .setLastKnownContactNumber(newListing.getLastKnownContactNumber()) .setCemeteryID(newListing.getCemeteryID()) .setSubscriberApprovedID(newListing.getSubscriberApprovedID()) .setSubscriberSubmitID(newListing.getSubscriberSubmitID()).setNames(newListing.getNames()) .setSubscriberSubmitID(subID).build(); //listingId, "Sam", "Winchester", "", "Male", "20/07/1980", "14/10/2014", "Came back", "2474", "/images/004.jpg", "Dean", "07255718927", subID, null id = updatePubserv.updatePublishedlistingReturn(updateListing); PublishedDeceasedListing pubUpdate = updatePubserv.find(id); Assert.assertNotNull(updatePubserv.find(id)); Assert.assertEquals(pubUpdate.getFirstName(), "Sam"); PublishedDeceasedListing pub = pubRepo.findOne(listingId); Assert.assertNotNull(pubRepo.findOne(listingId)); Assert.assertEquals(pub.getFirstName(), "Sam"); pubRepo.delete(newListing); subRepo.delete(newSub); updatePubserv.remove(updateListing); }
From source file:util.MyUtils.java
public static String getMonthString(int month) { switch (month - 1) { case Calendar.JANUARY: return "Jan"; case Calendar.FEBRUARY: return "Feb"; case Calendar.MARCH: return "Mar"; case Calendar.APRIL: return "Apr"; case Calendar.MAY: return "May"; case Calendar.JUNE: return "Jun"; case Calendar.JULY: return "Jul"; case Calendar.AUGUST: return "Aug"; case Calendar.SEPTEMBER: return "Sep"; case Calendar.OCTOBER: return "Oct"; case Calendar.NOVEMBER: return "Nov"; case Calendar.DECEMBER: return "Dec"; }/*from w w w .jav a 2s .c o m*/ return ""; }
From source file:com.cemeterylistingswebtest.test.services.ViewListingByDateOfBirthServiceTest.java
@Test(enabled = true) public void Test() { dateServ = ctx.getBean(ViewListingByDateOfBirthService.class); repoList = ctx.getBean(PublishedDeceasedListingRepository.class); subRepo = ctx.getBean(SubscriberRepository.class); userRepo = ctx.getBean(UserRoleRepository.class); //Initialise date Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2001); calendar.set(Calendar.MONTH, Calendar.MARCH); calendar.set(Calendar.DATE, 17); java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime()); //Initialise user role UserRole userRole = new UserRole.Builder().setLevel(2).build(); //userRepo.save(userRole); //userRoleID = userRole.getUserRoleID(); //Initialise subscriber Subscriber newSub = new Subscriber.Builder().setEmail("jGordan@gmail.com").setFirstName("james") .setSurname("gordan").setPwd("gotham").setUsername("commish").setSubscriptionDate(javaSqlDate) .setUserRoleID(userRole).build(); subRepo.save(newSub);/*from w w w .j a va2s. c o m*/ subID = newSub.getSubscriberID(); PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Dean") .setSurname("Winchester") .setGender("Male").setDateOfBirth("27/07/1985").setDateOfDeath("14/10/2014") .setGraveInscription("will probably come back").setGraveNumber("2474") .setImageOfBurialSite("/images/004.jpg").setLastKnownContactName("sam") .setLastKnownContactNumber("07255718927") .setSubscriberSubmitID(subID).build(); repoList.save(newListing); listingId = newListing.getPublishedListingID(); List<PublishedDeceasedListing> pubListDob = dateServ.findListingByDOB("27/07/1985"); Assert.assertFalse(pubListDob.isEmpty()); repoList.delete(listingId); subRepo.delete(subID); }