Example usage for java.util Calendar JANUARY

List of usage examples for java.util Calendar JANUARY

Introduction

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

Prototype

int JANUARY

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

Click Source Link

Document

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

Usage

From source file:org.jrimum.bopepo.TestFatorDeVencimento.java

@Test(expected = IllegalArgumentException.class)
public void testToFatorComDataMenorQueDataBase() {

    data.set(1997, Calendar.JANUARY, 1);

    FatorDeVencimento.toFator(data.getTime());
}

From source file:com.exxonmobile.ace.hybris.core.btg.condition.operand.valueproviders.OrganizationTotalSpentInCurrencyLastYearOperandValueProvider.java

@Override
public Object getValue(final BTGOrganizationTotalSpentInCurrencyLastYearOperandModel operand,
        final UserModel user, final BTGConditionEvaluationScope evaluationScope) {
    if (user instanceof B2BCustomerModel) {
        final B2BUnitModel unit = getB2bUnitService()
                .getRootUnit(getB2bUnitService().getParent((B2BCustomerModel) user));

        Date startDateInclusive = DateUtils.addYears(new Date(), -1);
        startDateInclusive = DateUtils.setHours(startDateInclusive, 0);
        startDateInclusive = DateUtils.setMinutes(startDateInclusive, 0);
        startDateInclusive = DateUtils.setSeconds(startDateInclusive, 0);
        startDateInclusive = DateUtils.setMonths(startDateInclusive, Calendar.JANUARY);
        startDateInclusive = DateUtils.setDays(startDateInclusive, 1);

        final Date endDateNonInclusive = DateUtils.addYears(startDateInclusive, 1);

        final double total = getTotalSpentByBranch(unit, operand.getCurrency(), startDateInclusive,
                endDateNonInclusive, operand.getProductCatalogId(), operand.getCategoryCode());
        return Double.valueOf(total);
    }//from  w  ww . j a  va  2s  .co m
    return Double.valueOf(0);
}

From source file:org.lieuofs.commune.biz.RechercheCommuneTest.java

@Test
public void recherche2012() {
    CommuneCritere critere = new CommuneCritere();
    Calendar cal = Calendar.getInstance();
    cal.set(2012, Calendar.JANUARY, 1);
    critere.setDateValiditeApres(cal.getTime());
    cal.set(2012, Calendar.DECEMBER, 31);
    critere.setDateValiditeAvant(cal.getTime());
    List<ICommuneSuisse> communes = gestionnaire.rechercher(critere);
    IterableAssert<Object> liste = assertThat(extractProperty("numeroOFS").from(communes));
    // La commune Collina d'Oro(5236) a absorb la commune Carabietta(5169) le 01.04.2012
    // Les 2 communes ont donc exist en 2012
    liste.contains(5236, 5169);/*w w w  .  ja  va  2 s  . c o  m*/
    // La commune Estavayer-le-Lac(2015) a absorb la commune Font(2017) le 01.01.2012
    liste.contains(2015).doesNotContain(2017);
    // La commune Val Terbi(6730) est ne de la fusion des communes Montsevelier(6717), Vermes(6726), Vicques(6727) le 01.01.2013
    liste.contains(6717, 6726, 6727).doesNotContain(6730);
    // 2496 communes valides en 2012 (2 doublons de numOFS !!)
    liste.hasSize(2498);

}

From source file:org.openehealth.coala.converter.PXSDateConverterTest.java

/**
 * @throws java.lang.Exception//from w ww. j  a  v  a  2s.  co m
 */
@Before
public void setUp() throws Exception {
    ResourceBundle properties = ResourceBundle.getBundle("coala-document");
    longPattern = properties.getString("coala.consent.longdatepattern");
    shortPattern = properties.getString("coala.consent.shortdatepattern");

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(Calendar.YEAR, 2011);
    cal.set(Calendar.MONTH, Calendar.JANUARY);
    cal.set(Calendar.DAY_OF_MONTH, 15);
    cal.set(Calendar.HOUR, 3);
    cal.set(Calendar.MINUTE, 36);
    cal.set(Calendar.SECOND, 50);
    cal.set(Calendar.MILLISECOND, 0);
    referenceDateLong = cal.getTime();

    cal = new GregorianCalendar();
    cal.set(Calendar.YEAR, 2011);
    cal.set(Calendar.MONTH, Calendar.JANUARY);
    cal.set(Calendar.DAY_OF_MONTH, 15);
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    referenceDateShort = cal.getTime();

}

From source file:org.lieuofs.commune.biz.GestionMutationCommuneTest.java

@Test
public void testRechercherMutationFribourg() {
    // Recherche des mutations sur le canton de Fribourg
    MutationCommuneCritere critere = new MutationCommuneCritere();
    critere.setCodeCanton("FR");
    Calendar cal = Calendar.getInstance();
    cal.set(2000, Calendar.JANUARY, 1);
    critere.setDateDebut(cal.getTime());
    List<IMutationCommune> mutations = gestionnaire.rechercherMutation(critere);
    List<String> descriptions = new ArrayList<String>();
    for (IMutationCommune mut : mutations) {
        descriptions.add(mut.getDescription());
    }/*from ww w .  j ava2 s .c o  m*/
    assertThat(mutations.size()).isGreaterThan(40);
}

From source file:adalid.commons.util.TimeUtils.java

public static synchronized Time currentTime() {
    calendar.setTimeInMillis(currentTimeMillis());
    calendar.set(Calendar.YEAR, 1970);
    calendar.set(Calendar.MONTH, Calendar.JANUARY);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    return new Time(calendar.getTimeInMillis());
}

From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.AmendmentXmlSerializerTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();

    element = registerMockFor(Element.class);
    deltaSerializer = registerMockFor(DefaultDeltaXmlSerializer.class);
    deltaSerializerFactory = registerMockFor(DeltaXmlSerializerFactory.class);

    amendment0 = setGridId("grid0", new Amendment());
    amendment0.setName("Amendment 0");
    amendment0.setDate(createDate(2008, Calendar.JANUARY, 1));

    delta = setGridId("grid1", new PlannedCalendarDelta());
    delta.setNode(setGridId("grid2", new PlannedCalendar()));
    delta.addChange(Add.create(new Epoch()));
    delta.getChanges().get(0).setUpdatedDate(createDate(2008, Calendar.JANUARY, 4));

    amendment1 = new Amendment();
    amendment1.setMandatory(true);/*w w  w.jav a  2 s . c  om*/
    amendment1.setName("Amendment 1");
    amendment1.setPreviousAmendment(amendment0);
    amendment1.setDate(createDate(2008, Calendar.JANUARY, 2));
    amendment1.setReleasedDate(createDate(2008, Calendar.JANUARY, 3));
    amendment1.addDelta(delta);

    QName qDelta = DocumentHelper.createQName("planned-calendar-delta",
            AbstractStudyCalendarXmlSerializer.DEFAULT_NAMESPACE);
    eDelta = DocumentHelper.createElement(qDelta);
    eDelta.addAttribute("id", delta.getGridId());
    eDelta.addAttribute("node-id", "grid2");

    QName qAmendment = DocumentHelper.createQName("amendment",
            AbstractStudyCalendarXmlSerializer.DEFAULT_NAMESPACE);
    eAmendment = DocumentHelper.createElement(qAmendment);
    eAmendment.addAttribute("mandatory", Boolean.valueOf(amendment1.isMandatory()).toString());
    eAmendment.addAttribute("name", amendment1.getName());

    study = createNamedInstance("Study A", Study.class);
    study.setAmendment(amendment0);

    serializer = new AmendmentXmlSerializer();
    serializer.setDeltaXmlSerializerFactory(deltaSerializerFactory);
    serializer.setStudy(study);
}

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";
    }//w  ww .j a  va 2s  .  c  o m
    return "";
}

From source file:org.jitsi.jicofo.reservation.ConferenceJsonTest.java

@Test
public void testToJson() {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, 2014);/*w  ww .  j  av a  2s .  c  o  m*/
    c.set(Calendar.MONTH, Calendar.JANUARY);
    c.set(Calendar.DAY_OF_MONTH, 8);
    c.set(Calendar.HOUR_OF_DAY, 9);
    c.set(Calendar.MINUTE, 2);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);

    Conference conf = new Conference("test1", "pawel.gawel", c.getTime());

    Map<String, Object> objects = conf.createJSonMap();

    assertEquals("test1", objects.get(ConferenceJsonHandler.CONF_NAME_KEY));
    assertEquals("pawel.gawel", objects.get(ConferenceJsonHandler.CONF_OWNER_KEY));

    // FIXME: This will fail in different time zone
    //assertEquals(
    //    "2014-01-08T09:02:00.000+01",
    //    objects.get(ConferenceJsonHandler.CONF_START_TIME_KEY));

    //assertEquals("00:05" ,objects.get(ConferenceJsonHandler
    //  .CONF_DURATION_KEY));
}

From source file:org.pentaho.metaverse.api.MetaverseLogicalIdGeneratorTest.java

@Test
public void testGenerateLogicalId() throws Exception {
    when(node.getProperty("name")).thenReturn("john doe");
    when(node.getProperty("age")).thenReturn(30);
    when(node.getProperty("address")).thenReturn("1234 Pentaho Way Orlando, FL 12345");
    Calendar cal = GregorianCalendar.getInstance();
    cal.set(1976, Calendar.JANUARY, 1, 0, 0, 0);
    when(node.getProperty("birthday")).thenReturn(cal.getTime());
    when(node.getPropertyKeys()).thenReturn(new HashSet<String>() {
        {//from w w w.  ja  v  a2  s.c  om
            add("address");
            add("age");
            add("birthday");
            add("name");
        }
    });

    // make sure there is no logicalid on the node initially
    assertNull(node.getProperty(DictionaryConst.PROPERTY_LOGICAL_ID));

    String logicalId = idGenerator.generateId(node);

    // it should come out in alphabetical order by key
    assertEquals(
            "{\"address\":\"1234 Pentaho Way Orlando, FL 12345\",\"age\":\"30\",\"birthday\":\"1976-01-01 00:00:00\",\"name\":\"john doe\"}",
            logicalId);

    // make sure the json string is parseable
    JsonNode jsonObject = objectMapper.readTree(logicalId);
    JsonNode address = jsonObject.get("address");
    assertEquals("1234 Pentaho Way Orlando, FL 12345", address.textValue());

    // make sure a call was made to add the logical id as a property
    verify(node).setProperty(DictionaryConst.PROPERTY_LOGICAL_ID, logicalId);

}