Example usage for java.util Calendar FEBRUARY

List of usage examples for java.util Calendar FEBRUARY

Introduction

In this page you can find the example usage for java.util Calendar FEBRUARY.

Prototype

int FEBRUARY

To view the source code for java.util Calendar FEBRUARY.

Click Source Link

Document

Value of the #MONTH field indicating the second month of the year in the Gregorian and Julian calendars.

Usage

From source file:it.caladyon.akka.molla.topology.Test_TimedListenerActor.java

/**
 * Arrivo di 3 messaggi dello stesso mittente nello stesso minuto (non dovrebbe capitare nella realta').
 *///from  w  w w  .j  a  va2s .c o m
@Ignore
@Test
public void test_1() {
    log.info("---- test 1 -------------------------------");

    // questo metodo di creazione delle Props e' ripreso da ActorSystemStarter
    final SpringExt springExtProvider = SpringExtensionProvider.springExtProvider.get(system);
    final Props props = springExtProvider.props(LISTENER_BEAN_NAME);
    final TestActorRef<TestTimedListenerActor> ref = TestActorRef.create(system, props, "test_1");
    final TestTimedListenerActor actor = ref.underlyingActor();

    try {
        List<Date> rd = new ArrayList<Date>();
        List<MessageWrapper> mv = new ArrayList<MessageWrapper>();
        List<Future<Object>> f = new ArrayList<Future<Object>>();
        int c = 0;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 10));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 20));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 30));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        try {
            Thread.sleep(WAIT + 100);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }

        for (int i = 0; i < f.size(); ++i) {
            assertTrue("future " + i, f.get(i).isCompleted());
        }

        assertTrue("execution count", actor.getExecCount() == 0);
        assertTrue("input size: " + actor.inputsSize(), actor.inputsSize() == 1);
    } finally {
        ref.stop();
    }
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.ResourceDependencyResolverServiceTest.java

@Test
public void findMostRelevantResource_before() {
    // given/*from w w  w . j av  a  2 s .  c om*/
    List<ResourceEntity> resources = new ArrayList<>();
    resources.add(r1);
    resources.add(r2);
    resources.add(r3);
    resources.add(r4);

    Calendar cal = new GregorianCalendar();
    cal.set(1999, Calendar.FEBRUARY, 1);
    Date relevantDate = new Date(cal.getTimeInMillis());

    // when
    ResourceEntity mostRelevantResource = service.findMostRelevantResource(resources, relevantDate);

    // then
    assertEquals(r1, mostRelevantResource);
}

From source file:it.caladyon.akka.molla.topology.help.Test_StrategistListenerActor_with_TolerantTimedListening_0.java

/**
 * Arrivo di 3 messaggi dello stesso mittente nello stesso minuto (non dovrebbe capitare nella realta').
 *//*from  w w  w.j  a  v  a  2s. c om*/
@SuppressWarnings("deprecation")
@Test
public void test_1() {
    log.info("---- test 1 -------------------------------");

    // questo metodo di creazione delle Props e' ripreso da ActorSystemStarter
    final SpringExt springExtProvider = SpringExtensionProvider.springExtProvider.get(system);
    final Props props = springExtProvider.props(LISTENER_BEAN_NAME);
    final TestActorRef<TestTolerantListenerActor> ref = TestActorRef.create(system, props, "test_1");
    final TestTolerantListenerActor actor = ref.underlyingActor();

    try {
        List<Date> rd = new ArrayList<Date>();
        List<MessageWrapper> mv = new ArrayList<MessageWrapper>();
        List<Future<Object>> f = new ArrayList<Future<Object>>();
        int c = 0;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 10));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 20));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 30));
        mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c));
        f.add(ask(ref, mv.get(c), TIMEOUT));
        ++c;

        try {
            Thread.sleep(WAIT + 100);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }

        for (int i = 0; i < f.size(); ++i) {
            assertTrue("future " + i, f.get(i).isCompleted());
        }

        assertTrue("execution count", actor.getExecCount() == 0);
        int inputsSize = ((TolerantTimedListening) actor.getListening()).inputs.size();
        assertTrue("input size: " + inputsSize, inputsSize == 1);
    } finally {
        ref.stop();
    }
}

From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java

/**
 * http://trac.cyberduck.ch/ticket/143//from   w w  w. j a v  a 2  s  .co m
 */
@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));
}

From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.ResourceDependencyResolverServiceTest.java

@Test
public void findMostRelevantResource_nextRel() {
    // given//from w  ww .j  a va  2 s.co m
    List<ResourceEntity> resources = new ArrayList<>();
    resources.add(r1);
    resources.add(r2);
    resources.add(r3);
    resources.add(r4);

    Calendar cal = new GregorianCalendar();
    cal.set(2002, Calendar.FEBRUARY, 1);
    Date relevantDate = new Date(cal.getTimeInMillis());

    // when
    ResourceEntity mostRelevantResource = service.findMostRelevantResource(resources, relevantDate);

    // then
    assertEquals(r3, mostRelevantResource);
}

From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java

public void shouldReturnOneHour() {
    Calendar end = prepareCalendar(2006, Calendar.FEBRUARY, 1, 11, 0, 0, 0);
    Calendar start = (Calendar) end.clone();
    start.add(Calendar.HOUR_OF_DAY, -1);
    setEndTime(end.getTimeInMillis());//ww  w.  j av  a2 s  .  c  o  m
    setStartTime(start.getTimeInMillis());
    expectedValue = messages.get("1Hour");
}

From source file:com.xing.api.JsonSerializationTest.java

private static void assertSchools(XingUser user) {
    School primarySchool = new School();
    primarySchool.id("42_abcdef");
    primarySchool.name("Carl-von-Ossietzky Universtt Schellenburg");
    primarySchool.degree("MSc CE/CS");
    List<String> notes = new ArrayList<>();
    notes.add("CS");
    notes.add("IT");
    notes.add("Android");
    primarySchool.notes(notes);/*www  .  ja  v a 2 s  .c  o  m*/
    primarySchool.beginDate(new SafeCalendar(1998, Calendar.AUGUST));
    primarySchool.endDate(new SafeCalendar(2005, Calendar.FEBRUARY));
    assertThat(user.educationBackground().primarySchool()).isEqualTo(primarySchool);

    School otherSchool = new School();
    otherSchool.id("42_abcdef");
    otherSchool.name("Carl-von-Ossietzky Universtt Schellenburg");
    otherSchool.degree("MSc CE/CS");
    otherSchool.subject("CE");
    otherSchool.beginDate(new SafeCalendar(1998, Calendar.AUGUST));
    otherSchool.endDate(new SafeCalendar(2005, Calendar.FEBRUARY));
    assertThat(user.educationBackground().schools()).containsExactly(otherSchool);
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting calendar number of month by month
 * description// w  ww .j  a v  a2  s.c  om
 * 
 * @param monthDescr
 * @return
 */
public static int getMonthNum(String monthDescr) {
    int numOfMonth = -1;
    if (DateTimeConstants.JANUARY.equals(monthDescr)) {
        numOfMonth = Calendar.JANUARY;
    }
    if (DateTimeConstants.FEBRUARY.equals(monthDescr)) {
        numOfMonth = Calendar.FEBRUARY;
    }
    if (DateTimeConstants.MARCH.equals(monthDescr)) {
        numOfMonth = Calendar.MARCH;
    }
    if (DateTimeConstants.APRIL.equals(monthDescr)) {
        numOfMonth = Calendar.APRIL;
    }
    if (DateTimeConstants.MAY.equals(monthDescr)) {
        numOfMonth = Calendar.MAY;
    }
    if (DateTimeConstants.JUNE.equals(monthDescr)) {
        numOfMonth = Calendar.JUNE;
    }
    if (DateTimeConstants.JULY.equals(monthDescr)) {
        numOfMonth = Calendar.JULY;
    }
    if (DateTimeConstants.AUGUST.equals(monthDescr)) {
        numOfMonth = Calendar.AUGUST;
    }
    if (DateTimeConstants.SEPTEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.SEPTEMBER;
    }
    if (DateTimeConstants.OCTOBER.equals(monthDescr)) {
        numOfMonth = Calendar.OCTOBER;
    }
    if (DateTimeConstants.NOVEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.NOVEMBER;
    }
    if (DateTimeConstants.DECEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.DECEMBER;
    }
    return numOfMonth;
}

From source file:com.swiftcorp.portal.common.util.CalendarUtils.java

@Deprecated
public static Calendar addMonthDayToCal(Calendar cal, int month, int day) {
    Date d = new Date();
    int daysToAdd = 0;
    // Calendar cal = Calendar.getInstance();
    int currentMonth = cal.get(2);
    long t = 0;/*from   w ww . j  a  va2  s. c om*/

    t = d.getTime();
    if (month > 0) {
        // cal.get ( month );
        for (int i = 0; i < month; i++) {
            if (currentMonth < 12) {
                if (currentMonth == Calendar.JANUARY) {
                    cal.set(2, Calendar.JANUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.FEBRUARY) {
                    cal.set(2, Calendar.FEBRUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MARCH) {
                    cal.set(2, Calendar.MARCH);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.APRIL) {
                    cal.set(2, Calendar.APRIL);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MAY) {
                    cal.set(2, Calendar.MAY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JUNE) {
                    cal.set(2, Calendar.JUNE);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JULY) {
                    cal.set(2, Calendar.JULY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.AUGUST) {
                    cal.set(2, Calendar.AUGUST);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.SEPTEMBER) {
                    cal.set(2, Calendar.SEPTEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.OCTOBER) {
                    cal.set(2, Calendar.OCTOBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.NOVEMBER) {
                    cal.set(2, Calendar.NOVEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.DECEMBER) {
                    cal.set(2, Calendar.DECEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                }
                currentMonth++;
            } else {
                currentMonth = 0;
                i--;
            }
        }
    }
    daysToAdd += day;
    // add the desired number of days to the long value using milli seconds

    t += daysToAdd * MILLIS_PER_DAY;
    cal.setTime(new Date(t));
    // and now you can format the date the way you want
    String result = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)) + "-"
            + Integer.toString(cal.get(Calendar.MONTH) + 1) + "-" + Integer.toString(cal.get(Calendar.YEAR));
    System.out.println("result month add::" + result);
    return cal;
}

From source file:com.clustercontrol.systemlog.bean.SyslogMessage.java

/**
 * ??//from  w  w w.  ja va  2s  .  c om
 * ?(String)Calendar?(int)???
 * 
 * @param month 
 * @return Calendar?
 */
private static int editCalendarMonth(String month) {

    switch (month.toUpperCase()) {
    case "JAN":
        return Calendar.JANUARY;
    case "FEB":
        return Calendar.FEBRUARY;
    case "MAR":
        return Calendar.MARCH;
    case "APR":
        return Calendar.APRIL;
    case "MAY":
        return Calendar.MAY;
    case "JUN":
        return Calendar.JUNE;
    case "JUL":
        return Calendar.JULY;
    case "AUG":
        return Calendar.AUGUST;
    case "SEP":
        return Calendar.SEPTEMBER;
    case "OCT":
        return Calendar.OCTOBER;
    case "NOV":
        return Calendar.NOVEMBER;
    case "DEC":
        return Calendar.DECEMBER;
    }
    return Calendar.UNDECIMBER;
}