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:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testJpLocales() {

    final Calendar cal = Calendar.getInstance(GMT);
    cal.clear();/*from w  w w.  j  a  v  a  2s  . com*/
    cal.set(2003, Calendar.FEBRUARY, 10);
    cal.set(Calendar.ERA, GregorianCalendar.BC);

    final Locale locale = LocaleUtils.toLocale("zh");
    {
        // ja_JP_JP cannot handle dates before 1868 properly

        final SimpleDateFormat sdf = new SimpleDateFormat(LONG_FORMAT, locale);
        final DateParser fdf = getInstance(LONG_FORMAT, locale);

        try {
            checkParse(locale, cal, sdf, fdf);
        } catch (final ParseException ex) {
            Assert.fail("Locale " + locale + " failed with " + LONG_FORMAT + "\n" + trimMessage(ex.toString()));
        }
    }
}

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

/**
 * Controllo della generazione degli {@link HeartBeat} giusti.
 * Estensione di {@link #test_0()} con quanto fatto in {@link Test_DeltaDelayActor#test_HeartBeat()}.
 *///from   w  w w  .  j  a va 2 s .co m
@Ignore
@Test
public void test_HeartBeat() {
    log.info("---- test_HeartBeat -------------------------------");

    // 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_3");
    final TestTimedListenerActor actor = ref.underlyingActor();

    final TestActorRef<HeartBeatTestingActor> proberef = TestActorRef.create(system,
            springExtProvider.props(PROBE_ACTOR_BEAN_NAME), "probe_0");
    final HeartBeatTestingActor probe = proberef.underlyingActor();

    try {
        final Date d1 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 00);
        final MessageWrapper mw1 = new MessageWrapper(SOURCE1_BEAN_NAME, d1, "message1");
        final Future<Object> future1 = ask(ref, mw1, TIMEOUT);

        final Date d2 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 01);
        final MessageWrapper mw2 = new MessageWrapper(SOURCE2_BEAN_NAME, d2, "message2");
        final Future<Object> future2 = ask(ref, mw2, TIMEOUT);

        final Date d3 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 02);
        final MessageWrapper mw3 = new MessageWrapper(SOURCE3_BEAN_NAME, d3, "message3");
        final Future<Object> future3 = ask(ref, mw3, TIMEOUT);

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

        assertTrue("future1", future1.isCompleted());
        assertTrue("future2", future2.isCompleted());
        assertTrue("future3", future3.isCompleted());

        try {
            assertTrue("response3", Await.result(future3, Duration.Zero()) == d3);
        } catch (Exception e) {
            e.printStackTrace();
        }

        assertTrue("execution count", actor.getExecCount() == 1);

        Assert.assertTrue("number of beats: " + probe.getTotal(), probe.getTotal() == actor.getExecCount());
    } finally {
        proberef.stop();
        ref.stop();
    }
}

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

/**
 * Controllo della generazione degli {@link HeartBeat} giusti.
 * Estensione di {@link #test_0()} con quanto fatto in {@link Test_DeltaDelayActor#test_HeartBeat()}.
 * @throws Exception//from   www .j  a  v a2 s .  c o m
 */
@SuppressWarnings("deprecation")
@Test
public void test_HeartBeat() throws Exception {
    log.info("---- test_HeartBeat -------------------------------");

    // 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_3");
    final TestTimedListenerActor actor = ref.underlyingActor();

    final TestActorRef<HeartBeatTestingActor> proberef = TestActorRef.create(system,
            springExtProvider.props(PROBE_ACTOR_BEAN_NAME), "probe_0");
    final HeartBeatTestingActor probe = proberef.underlyingActor();

    try {
        final Date d1 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 00);
        final MessageWrapper mw1 = new MessageWrapper(SOURCE1_BEAN_NAME, d1, "message1");
        final Future<Object> future1 = ask(ref, mw1, TIMEOUT);

        final Date d2 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 01);
        final MessageWrapper mw2 = new MessageWrapper(SOURCE2_BEAN_NAME, d2, "message2");
        final Future<Object> future2 = ask(ref, mw2, TIMEOUT);

        final Date d3 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 02);
        final MessageWrapper mw3 = new MessageWrapper(SOURCE3_BEAN_NAME, d3, "message3");
        final Future<Object> future3 = ask(ref, mw3, TIMEOUT);

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

        assertTrue("future1", future1.isCompleted());
        assertTrue("future2", future2.isCompleted());
        assertTrue("future3", future3.isCompleted());

        assertTrue("response3", Await.result(future3, Duration.Zero()) == d3);

        assertTrue("execution count", actor.getExecCount() == 1);

        Assert.assertTrue("number of beats: " + probe.getTotal(), probe.getTotal() == actor.getExecCount());
    } finally {
        proberef.stop();
        ref.stop();
    }
}

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

/**
 * Controllo della generazione degli {@link HeartBeat} giusti.
 * Estensione di {@link #test_0()} con quanto fatto in {@link Test_DeltaDelayActor#test_HeartBeat()}.
 * @throws Exception//from  w ww . ja v  a 2s .com
 */
@SuppressWarnings("deprecation")
@Test
public void test_HeartBeat() throws Exception {
    log.info("---- test_HeartBeat -------------------------------");

    // 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_3");
    final TestTolerantListenerActor actor = ref.underlyingActor();

    final TestActorRef<HeartBeatTestingActor> proberef = TestActorRef.create(system,
            springExtProvider.props(PROBE_ACTOR_BEAN_NAME), "probe_0");
    final HeartBeatTestingActor probe = proberef.underlyingActor();

    try {
        final Date d1 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 00);
        final MessageWrapper mw1 = new MessageWrapper(SOURCE1_BEAN_NAME, d1, "message1");
        final Future<Object> future1 = ask(ref, mw1, TIMEOUT);

        final Date d2 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 01);
        final MessageWrapper mw2 = new MessageWrapper(SOURCE2_BEAN_NAME, d2, "message2");
        final Future<Object> future2 = ask(ref, mw2, TIMEOUT);

        final Date d3 = new Date(2015, Calendar.FEBRUARY, 27, 12, 00, 02);
        final MessageWrapper mw3 = new MessageWrapper(SOURCE3_BEAN_NAME, d3, "message3");
        final Future<Object> future3 = ask(ref, mw3, TIMEOUT);

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

        assertTrue("future1", future1.isCompleted());
        assertTrue("future2", future2.isCompleted());
        assertTrue("future3", future3.isCompleted());

        assertTrue("response3", Await.result(future3, Duration.Zero()) == d3);

        assertTrue("execution count", actor.getExecCount() == 1);

        Assert.assertTrue("number of beats: " + probe.getTotal(), probe.getTotal() == actor.getExecCount());
    } finally {
        proberef.stop();
        ref.stop();
    }
}

From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java

private int month(String sMonth) {
    if (isEmpty(sMonth)) {
        return -1;
    }//from w w w. j  a v a  2 s.  c  om
    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   w  w w .ja  v a  2 s  . com
    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:org.jfree.data.time.TimeSeriesCollectionTest.java

@Test
public void testGetRangeBounds2() {
    TimeZone tzone = TimeZone.getTimeZone("Europe/London");
    Calendar calendar = new GregorianCalendar(tzone, Locale.UK);
    calendar.clear();/*  w ww . j  ava  2s  .  com*/
    calendar.set(2014, Calendar.FEBRUARY, 23, 6, 0);
    long start = calendar.getTimeInMillis();
    calendar.clear();
    calendar.set(2014, Calendar.FEBRUARY, 24, 18, 0);
    long end = calendar.getTimeInMillis();
    Range range = new Range(start, end);

    TimeSeriesCollection collection = new TimeSeriesCollection(tzone);
    assertNull(collection.getRangeBounds(Collections.EMPTY_LIST, range, true));

    TimeSeries s1 = new TimeSeries("S1");
    s1.add(new Day(24, 2, 2014), 10.0);
    collection.addSeries(s1);
    assertEquals(new Range(10.0, 10.0), collection.getRangeBounds(Arrays.asList("S1"), range, true));
    collection.setXPosition(TimePeriodAnchor.MIDDLE);
    assertEquals(new Range(10.0, 10.0), collection.getRangeBounds(Arrays.asList("S1"), range, true));
    collection.setXPosition(TimePeriodAnchor.END);
    assertNull(collection.getRangeBounds(Arrays.asList("S1"), range, true));
}

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:/*w w  w  .j ava2 s  .c  o m*/
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testParseNumerics() throws ParseException {
    final Calendar cal = Calendar.getInstance(NEW_YORK, Locale.US);
    cal.clear();/*from  w  ww .j  a v  a  2s  .c o m*/
    cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20);
    cal.set(Calendar.MILLISECOND, 989);

    final DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US);
    assertEquals(cal.getTime(), fdf.parse("20030210153320989"));
}

From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testQuotes() throws ParseException {
    final Calendar cal = Calendar.getInstance(NEW_YORK, Locale.US);
    cal.clear();// w w  w.ja va2  s .c o m
    cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20);
    cal.set(Calendar.MILLISECOND, 989);

    final DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US);
    assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'"));
}