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:org.hawkular.alerts.api.model.action.TimeConstraint.java
private int month(String sMonth) { if (isEmpty(sMonth)) { return -1; }// w w w . ja v a 2 s. c o 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:de.gebatzens.sia.SIAApp.java
public String getSeasonTheme() { int m = Calendar.getInstance().get(Calendar.MONTH); switch (m) {/*from ww w .j a v a 2 s.c o m*/ case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: return "Winter"; default: return "Summer"; } }
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 . ja va2 s . c o m throw new IllegalArgumentException("Invalid Month"); } }
From source file:agency.AgencyManagerImplTest.java
private static Mission newMission01() { Calendar missionBegin = new GregorianCalendar(2015, Calendar.JANUARY, 1); Calendar missionEnd = new GregorianCalendar(2015, Calendar.MARCH, 11); return newMission("The Avengers", missionBegin.getTime(), missionEnd.getTime(), 3, 3, "code name - PV168"); }
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 . ja v a2s.co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:edu.tsinghua.lumaqq.ui.dialogs.LoginDialog.java
/** * logo/*from www.j av a2 s.co m*/ * * @param lblLogo */ private void setLogo(Label lblLogo) { Calendar c = Calendar.getInstance(); if (c.get(Calendar.MONTH) == Calendar.MARCH) { //System.out.println(c.get(Calendar.MONTH)+"\tEEE:"+Calendar.MARCH); lblLogo.setImage(Resources.getInstance().getImage(Resources.bmpSmth)); } else if (c.get(Calendar.HOUR_OF_DAY) >= 20) { //System.out.println(c.get(Calendar.MONTH)+"\tDDD:"+Calendar.MARCH); lblLogo.setImage(Resources.getInstance().getImage(Resources.bmpLogin2)); } else { lblLogo.setImage(Resources.getInstance().getImage(Resources.bmpLogin)); // System.out.println(c.get(Calendar.MONTH)+"\tGGGGGGG:"+Calendar.MARCH); } }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * ?// w w w . jav a 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; }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * //from w ww . j a v a 2s. co m * 1 2 3 4 * * @param date * @return */ public static int getSeason(Date date) { int season = 0; Calendar c = Calendar.getInstance(); c.setTime(date); int month = c.get(Calendar.MONTH); switch (month) { case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: season = 1; break; case Calendar.APRIL: case Calendar.MAY: case Calendar.JUNE: season = 2; break; case Calendar.JULY: case Calendar.AUGUST: case Calendar.SEPTEMBER: season = 3; break; case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: season = 4; break; default: break; } return season; }
From source file:com.silverpeas.mailinglist.service.model.dao.TestMessageDao.java
@Test public void testListMessagesOfMailingList() throws Exception { MessageDao messageDao = getMessageDAO(); Calendar sentDate = Calendar.getInstance(); sentDate.set(Calendar.YEAR, 2008); sentDate.set(Calendar.MONTH, Calendar.MARCH); sentDate.set(Calendar.DAY_OF_MONTH, 15); sentDate.set(Calendar.HOUR_OF_DAY, 9); sentDate.set(Calendar.MINUTE, 0); sentDate.set(Calendar.SECOND, 0); sentDate.set(Calendar.MILLISECOND, 0); Message message = new Message(); message.setBody(textEmailContent);/*w w w .ja v a2s . c o m*/ message.setComponentId("componentId"); message.setModerated(true); message.setSummary(textEmailContent.substring(0, 200)); message.setSender("bart.simpson@ilverpeas.com"); message.setMessageId("0000001747b40c16"); message.setSentDate(sentDate.getTime()); message.setTitle("Simple text message"); Attachment attachment = new Attachment(); attachment.setPath(attachmentPath + "lemonde.html"); attachment.setFileName("lemonde.html"); attachment.setSize(10000); message.getAttachments().add(attachment); attachment = new Attachment(); attachment.setPath(attachmentPath + "lemonde2.html"); attachment.setFileName("lemonde2.html"); attachment.setSize(20000); message.getAttachments().add(attachment); messageDao.saveMessage(message); message = new Message(); message.setBody(textEmailContent); message.setComponentId("componentId"); message.setModerated(false); message.setSummary(textEmailContent.substring(0, 200)); message.setSender("bart.simpson@ilverpeas.com"); message.setMessageId("0000001747b40c17"); message.setSentDate(sentDate.getTime()); message.setTitle("Simple text message 2"); messageDao.saveMessage(message); sentDate.set(Calendar.YEAR, 2008); sentDate.set(Calendar.MONTH, Calendar.FEBRUARY); sentDate.set(Calendar.DAY_OF_MONTH, 17); sentDate.set(Calendar.HOUR_OF_DAY, 9); sentDate.set(Calendar.MINUTE, 0); sentDate.set(Calendar.SECOND, 0); sentDate.set(Calendar.MILLISECOND, 0); message = new Message(); message.setBody(textEmailContent); message.setComponentId("componentId"); message.setModerated(true); message.setSummary(textEmailContent.substring(0, 200)); message.setSender("bart.simpson@ilverpeas.com"); message.setMessageId("0000001747b40c18"); message.setSentDate(sentDate.getTime()); message.setTitle("Simple text message 3"); messageDao.saveMessage(message); List messages = messageDao.listAllMessagesOfMailingList("componentId", 0, 10, orderByDate); assertNotNull(messages); assertEquals(3, messages.size()); assertEquals(3, countRowsInTable("SC_MAILINGLIST_MESSAGE")); assertEquals(2, countRowsInTable("SC_MAILINGLIST_ATTACHMENT")); messages = messageDao.listAllMessagesOfMailingList("componentId", 0, 2, orderByDate); assertNotNull(messages); assertEquals(2, messages.size()); messages = messageDao.listAllMessagesOfMailingList("componentId", 1, 2, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", -1, -1, 0, 10, orderByDate); assertNotNull(messages); assertEquals(2, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", -1, 2008, 0, 10, orderByDate); assertNotNull(messages); assertEquals(2, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", -1, 2007, 0, 10, orderByDate); assertNotNull(messages); assertEquals(0, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", Calendar.MARCH, 2008, 0, 10, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", Calendar.FEBRUARY, 2008, 0, 10, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", -1, -1, 0, 1, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listDisplayableMessagesOfMailingList("componentId", -1, -1, 1, 1, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listUnmoderatedMessagesOfMailingList("componentId", 0, 10, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listUnmoderatedMessagesOfMailingList("componentId", 0, 1, orderByDate); assertNotNull(messages); assertEquals(1, messages.size()); messages = messageDao.listUnmoderatedMessagesOfMailingList("componentId", 1, 1, orderByDate); assertNotNull(messages); assertEquals(0, messages.size()); assertEquals(3, countRowsInTable("SC_MAILINGLIST_MESSAGE")); assertEquals(2, countRowsInTable("SC_MAILINGLIST_ATTACHMENT")); long unmoderatedMessages = messageDao.listTotalNumberOfUnmoderatedMessages("componentId"); assertEquals(1, unmoderatedMessages); long displayabledMessages = messageDao.listTotalNumberOfDisplayableMessages("componentId"); assertEquals(2, displayabledMessages); long totalMessages = messageDao.listTotalNumberOfMessages("componentId"); assertEquals(3, totalMessages); }
From source file:myorg.relex.One2OneTest.java
/** * This test demonstrates use of cascades in a one-to-one * bi-directional relationship where all cascades come * from the inverse/parent side of the relationship. *//*from w w w .ja va 2s .c om*/ @Test public void testOne2OneCascadeFromInverse() { log.info("*** testOne2OneCascadeFromInverse ***"); Ticket ticket = new Ticket(); ticket.setDate(new GregorianCalendar(2013, Calendar.MARCH, 16).getTime()); Passenger passenger = new Passenger(ticket, "Fred"); //set inverse side ticket.setPassenger(passenger); //set the owning side em.persist(ticket); //persist from inverse side em.flush(); assertTrue("ticket not managed", em.contains(ticket)); assertTrue("passenger not managed", em.contains(passenger)); log.debug("detach both instances from the persistence context"); em.detach(ticket); assertFalse("ticket managed", em.contains(ticket)); assertFalse("passenger managed", em.contains(passenger)); log.debug("perform a bulk update to both objects"); ticket = em.find(Ticket.class, ticket.getId()); Date newDate = new GregorianCalendar(2013, Calendar.APRIL, 1).getTime(); String newName = "Frederick"; em.createQuery("update Ticket t set t.date=:date").setParameter("date", newDate, TemporalType.DATE) .executeUpdate(); em.createQuery("update Passenger p set p.name=:name where p.name='Fred'").setParameter("name", newName) .executeUpdate(); assertFalse("unexpected date", newDate.equals(ticket.getDate())); assertFalse("unexpected name", newName.equals(ticket.getPassenger().getName())); em.refresh(ticket); assertTrue("date not refreshed", newDate.equals(ticket.getDate())); assertTrue("name not refreshed", newName.equals(ticket.getPassenger().getName())); log.debug("merging changes from inverse side"); Ticket ticket2 = new Ticket(ticket.getId()); ticket2.setDate(new GregorianCalendar(2014, Calendar.APRIL, 1).getTime()); Passenger passenger2 = new Passenger(passenger.getId()); passenger2.setName("Rick"); ticket2.setPassenger(passenger2); passenger2.setTicket(ticket2); assertFalse("unexpected date", ticket2.getDate().equals(ticket.getDate())); assertFalse("unexpected name", ticket2.getPassenger().getName().equals(ticket.getPassenger().getName())); ticket = em.merge(ticket2); em.flush(); assertTrue("date not merged", ticket2.getDate().equals(ticket.getDate())); assertTrue("name not merged", ticket2.getPassenger().getName().equals(ticket.getPassenger().getName())); log.debug("delete the entities from the inverse side"); assertNotNull("ticket not found", em.find(Ticket.class, ticket.getId())); assertNotNull("passenger not found", em.find(Passenger.class, ticket.getPassenger().getId())); em.remove(ticket); em.flush(); assertNull("ticket not removed", em.find(Ticket.class, ticket.getId())); assertNull("passenger not removed", em.find(Passenger.class, ticket.getPassenger().getId())); }