Example usage for java.util Calendar DECEMBER

List of usage examples for java.util Calendar DECEMBER

Introduction

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

Prototype

int DECEMBER

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

Click Source Link

Document

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

Usage

From source file:net.sourceforge.openutils.mgnlcriteria.jcr.query.CriteriaTest.java

/**
 * @return//  w  w w. j  a v  a 2 s  .co  m
 */
private Criteria toXpathExpressionJavadocExampleCriteria() {
    Calendar begin = Calendar.getInstance();
    begin.set(1999, Calendar.JANUARY, 1);
    Calendar end = Calendar.getInstance();
    end.set(2001, Calendar.DECEMBER, 31);

    Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(RepositoryConstants.WEBSITE)
            .setBasePath("/pets").add(Restrictions.contains("@title", "Lucky"))
            .add(Restrictions.eq("@petType", "dog")).add(Restrictions.betweenDates("@birthDate", begin, end))
            .addOrder(Order.desc("@title"));
    return criteria;
}

From source file:ISO8601DateTimeFormat.java

/**
 * Write century, year, and months.// w  w  w  . j a va  2s .c  o  m
 * @param sbuf The buffer to append the string.
 */
protected final void writeCCYYMM(StringBuffer sbuf) {
    int year = calendar.get(Calendar.YEAR);
    appendInt(sbuf, year, 4);

    String month;
    switch (calendar.get(Calendar.MONTH)) {
    case Calendar.JANUARY:
        month = "-01-";
        break;
    case Calendar.FEBRUARY:
        month = "-02-";
        break;
    case Calendar.MARCH:
        month = "-03-";
        break;
    case Calendar.APRIL:
        month = "-04-";
        break;
    case Calendar.MAY:
        month = "-05-";
        break;
    case Calendar.JUNE:
        month = "-06-";
        break;
    case Calendar.JULY:
        month = "-07-";
        break;
    case Calendar.AUGUST:
        month = "-08-";
        break;
    case Calendar.SEPTEMBER:
        month = "-09-";
        break;
    case Calendar.OCTOBER:
        month = "-10-";
        break;
    case Calendar.NOVEMBER:
        month = "-11-";
        break;
    case Calendar.DECEMBER:
        month = "-12-";
        break;
    default:
        month = "-NA-";
        break;
    }
    sbuf.append(month);

    int day = calendar.get(Calendar.DAY_OF_MONTH);
    appendInt(sbuf, day, 2);
}

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

private static void assertCompanies(XingUser user) throws Exception {
    Company first = buildPrimaryCompany();

    Company second = new Company().id("24_abcdef").name("Ninja Ltd.").title("DevOps").tag("NINJA")
            .url("http://www.ninja-ltd.co.uk").beginDate(new SafeCalendar(2009, Calendar.APRIL))
            .endDate(new SafeCalendar(2010, Calendar.JULY))
            .industries(/*from   www  .  j ava2s  . com*/
                    Collections.singletonList(new Industry(220800, "Athletes, organisers and associations")))
            .formOfEmployment(FormOfEmployment.OWNER)
            .discipline(new Discipline("12_05e01e", "IT_AND_SOFTWARE_DEVELOPMENT"));

    Company third = new Company().id("45_abcdef").title("Wiss. Mitarbeiter").tag("OFFIS")
            .url("http://www.uni.de").beginDate(new SafeCalendar(2007)).endDate(new SafeCalendar(2008))
            .industries(Collections.singletonList(new Industry(20400, "Fashion and textiles")))
            .formOfEmployment(FormOfEmployment.PART_TIME_EMPLOYEE)
            .discipline(new Discipline("9_5e231a", "TEACHING_R_AND_D"));

    Company forth = new Company().id("176_abcdef").title("TEST NINJA").companySize(CompanySize.SIZE_201_500)
            .tag("TESTCOMPANY").careerLevel(CareerLevel.ENTRY_LEVEL)
            .beginDate(new SafeCalendar(1998, Calendar.DECEMBER)).endDate(new SafeCalendar(1999, Calendar.MAY))
            .industries(
                    Collections.singletonList(new Industry(220800, "Athletes, organisers and associations")))
            .formOfEmployment(FormOfEmployment.INTERN);

    assertThat(user.professionalExperience().companies()).containsExactly(first, second, third, forth);
}

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

/**
 * This method is used for getting month long description
 * /*  w  ww .ja  va2  s .  co m*/
 * @param mthNum
 * @return
 */
public static String getMonthLongDesc(int mthNum) {
    String mthLongDesc;

    switch (mthNum) {
    case Calendar.JANUARY: {
        mthLongDesc = DateTimeConstants.JANUARY;
        break;
    }
    case Calendar.FEBRUARY: {
        mthLongDesc = DateTimeConstants.FEBRUARY;
        break;
    }
    case Calendar.MARCH: {
        mthLongDesc = DateTimeConstants.MARCH;
        break;
    }
    case Calendar.APRIL: {
        mthLongDesc = DateTimeConstants.APRIL;
        break;
    }
    case Calendar.MAY: {
        mthLongDesc = DateTimeConstants.MAY;
        break;
    }
    case Calendar.JUNE: {
        mthLongDesc = DateTimeConstants.JUNE;
        break;
    }
    case Calendar.JULY: {
        mthLongDesc = DateTimeConstants.JULY;
        break;
    }
    case Calendar.AUGUST: {
        mthLongDesc = DateTimeConstants.AUGUST;
        break;
    }
    case Calendar.SEPTEMBER: {
        mthLongDesc = DateTimeConstants.SEPTEMBER;
        break;
    }
    case Calendar.OCTOBER: {
        mthLongDesc = DateTimeConstants.OCTOBER;
        break;
    }
    case Calendar.NOVEMBER: {
        mthLongDesc = DateTimeConstants.NOVEMBER;
        break;
    }
    case Calendar.DECEMBER: {
        mthLongDesc = DateTimeConstants.DECEMBER;
        break;
    }
    default: {
        mthLongDesc = "";
        break;
    }
    }

    return mthLongDesc;
}

From source file:net.sourceforge.openutils.mgnlcriteria.jcr.query.CriteriaTest.java

/**
 * Tests pagination of results./*from  www. j  ava 2s  .c  o m*/
 * @throws Exception
 */
@Test
public void testSetFirstResultAndMaxResults() throws Exception {
    Calendar begin = Calendar.getInstance();
    begin.set(1999, Calendar.JANUARY, 1);
    Calendar end = Calendar.getInstance();
    end.set(2001, Calendar.DECEMBER, 31);

    Criteria criteria = JCRCriteriaFactory.createCriteria().setWorkspace(RepositoryConstants.WEBSITE)
            .setBasePath("/pets").add(Restrictions.betweenDates("@birthDate", begin, end))
            .addOrder(Order.asc("@birthDate")).setFirstResult(5).setMaxResults(5);

    AdvancedResult result = criteria.execute();
    // first page:
    // --- 9 (title=Lucky, petType=bird, birthDate=1999-08-06)
    // --- 6 (title=George, petType=snake, birthDate=2000-01-20)
    // --- 4 (title=Jewel, petType=dog, birthDate=2000-03-07)
    // --- 11 (title=Freddy, petType=bird, birthDate=2000-03-09)
    // --- 12 (title=Lucky, petType=dog, birthDate=2000-06-24)
    // second page:
    // --- 1 (title=Leo, petType=cat, birthDate=2000-09-07)
    // --- 5 (title=Iggy, petType=lizard, birthDate=2000-11-30)
    // --- 3 (title=Rosy, petType=dog, birthDate=2001-04-17)
    Assert.assertEquals(result.getTotalSize(), 8);

    ResultIterator<? extends Node> iterator = result.getItems();
    Assert.assertEquals(iterator.getSize(), 3);
    Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "1");
    Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "5");
    Assert.assertEquals(CriteriaTestUtils.name(iterator.next()), "3");
}

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSHistoryFileToSQL.java

private Date getSystemReleaseDate(String releaseId) throws Exception {
    String sYear = releaseId.substring(0, 4);
    int year = new Integer(sYear).intValue();

    String sMonth = releaseId.substring(4);
    int mon = 0;//w  w  w. jav a  2s .  c  o m

    Calendar cal = Calendar.getInstance();
    if ("AA".equalsIgnoreCase(sMonth)) {
        mon = Calendar.JANUARY;
    } else if ("AB".equalsIgnoreCase(sMonth)) {
        mon = Calendar.APRIL;
    } else if ("AC".equalsIgnoreCase(sMonth)) {
        mon = Calendar.JULY;
    } else if ("AD".equalsIgnoreCase(sMonth)) {
        mon = Calendar.OCTOBER;
    } else {
        try {
            int i = Integer.parseInt(sMonth);

            switch (i) {
            case 1:
                mon = Calendar.JANUARY;
                break;
            case 2:
                mon = Calendar.FEBRUARY;
                break;
            case 3:
                mon = Calendar.MARCH;
                break;
            case 4:
                mon = Calendar.APRIL;
                break;
            case 5:
                mon = Calendar.MAY;
                break;
            case 6:
                mon = Calendar.JUNE;
                break;
            case 7:
                mon = Calendar.JULY;
                break;
            case 8:
                mon = Calendar.AUGUST;
                break;
            case 9:
                mon = Calendar.SEPTEMBER;
                break;
            case 10:
                mon = Calendar.OCTOBER;
                break;
            case 11:
                mon = Calendar.NOVEMBER;
                break;
            case 12:
                mon = Calendar.DECEMBER;
                break;

            default:
                throw new Exception("Release ID is not in required format: " + sMonth);
            }
        } catch (NumberFormatException e) {
            throw new Exception("Release ID is not in required format." + sMonth);
        }

    }
    cal.set(year, mon, 01, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);

    return new Date(cal.getTimeInMillis());
}

From source file:edu.umm.radonc.ca_dash.model.ActivityFacade.java

public TreeMap<String, SynchronizedDescriptiveStatistics> getWeeklySummaryStats(Date start, Date end,
        Long hospitalser, boolean imrtOnly, boolean includeWeekends) {
    Calendar cal = new GregorianCalendar();
    TreeMap<String, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();

    List<Object[]> events;

    if (hospitalser < 0) {
        events = getDailyCounts(start, end, imrtOnly, includeWeekends);
    } else {//from   www  .  j  a  va 2s .co  m
        events = getDailyCounts(start, end, hospitalser, imrtOnly, includeWeekends);
    }
    cal.setTime(start);
    int wk = cal.get(Calendar.WEEK_OF_YEAR);
    int mo = cal.get(Calendar.MONTH);
    int yr = cal.get(Calendar.YEAR);
    if (mo == Calendar.DECEMBER && wk == 1) {
        yr = yr + 1;
    } else if (mo == Calendar.JANUARY && wk == 52) {
        yr = yr - 1;
    }
    String currYrWk = yr + "-" + String.format("%02d", wk);
    String prevYrWk = "";
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    while (cal.getTime().before(end) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        prevYrWk = currYrWk;
        cal.setTime(d);
        wk = cal.get(Calendar.WEEK_OF_YEAR);
        mo = cal.get(Calendar.MONTH);
        yr = cal.get(Calendar.YEAR);
        if (mo == Calendar.DECEMBER && wk == 1) {
            yr = yr + 1;
        } else if (mo == Calendar.JANUARY && wk == 52) {
            yr = yr - 1;
        }
        currYrWk = yr + "-" + String.format("%02d", wk);

        if (!(prevYrWk.equals(currYrWk))) {
            retval.put(prevYrWk, currStats);
            currStats = new SynchronizedDescriptiveStatistics();
        }

        currStats.addValue(count);
        i++;
    }
    retval.put(prevYrWk, currStats);

    return retval;
}

From source file:com.feilong.core.date.CalendarUtil.java

/**
 * ?,? <code>1231? 23:59:59.999</code>
 *
 * @param calendar/* ww  w . j av  a 2  s  .  co m*/
 *            the calendar
 * @return  <code>calendar</code> null, {@link NullPointerException}
 * @since 1.3.0
 * @see #resetDayEnd(Calendar)
 */
static Calendar resetYearEnd(Calendar calendar) {
    Validate.notNull(calendar, "calendar can't be null!");
    calendar.set(Calendar.MONTH, Calendar.DECEMBER);
    calendar.set(Calendar.DAY_OF_MONTH, 31);
    return resetDayEnd(calendar);
}

From source file:edu.virginia.iath.oxygenplugins.dateparser.helpers.SNACDate.java

private Calendar[] getSeasonDates(String seasonStr, int year) {
    Calendar[] seasonDates = new Calendar[2];
    String season = seasonStr.toLowerCase().trim();

    seasonDates[0] = Calendar.getInstance();
    seasonDates[1] = Calendar.getInstance();

    // Note: Java is WEIRD:  0 = JANUARY, 1 = FEBRUARY, ...
    if (season.equals("winter")) {
        seasonDates[0].set(year - 1, Calendar.DECEMBER, 21);
        seasonDates[1].set(year, Calendar.MARCH, 19);

    } else if (season.equals("spring")) {
        seasonDates[0].set(year, Calendar.MARCH, 20);
        seasonDates[1].set(year, Calendar.JUNE, 20);

    } else if (season.equals("fall") || season.equals("autumn")) {
        seasonDates[0].set(year, Calendar.SEPTEMBER, 22);
        seasonDates[1].set(year, Calendar.DECEMBER, 20);

    } else if (season.equals("summer")) {
        seasonDates[0].set(year, Calendar.JUNE, 21);
        seasonDates[1].set(year, Calendar.SEPTEMBER, 21);

    }//  www .  ja  v a2s  . c  o m

    return seasonDates;
}

From source file:com.streamsets.pipeline.lib.remote.FTPAndSSHDUnitTest.java

private X509Certificate generateCertificate(KeyPair keyPair) throws Exception {
    Date from = new Date();
    Date to = new GregorianCalendar(2037, Calendar.DECEMBER, 31).getTime();
    X500Name subject = new X500Name("CN=localhost");
    SubjectPublicKeyInfo subPubKeyInfo = SubjectPublicKeyInfo.getInstance(keyPair.getPublic().getEncoded());
    X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(subject,
            new BigInteger(64, new SecureRandom()), from, to, subject, subPubKeyInfo);
    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA512WITHRSA");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
    ContentSigner contentSigner = new BcRSAContentSignerBuilder(sigAlgId, digAlgId)
            .build(PrivateKeyFactory.createKey(keyPair.getPrivate().getEncoded()));
    X509CertificateHolder certHolder = certBuilder.build(contentSigner);
    return new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHolder);
}