Example usage for java.util Calendar OCTOBER

List of usage examples for java.util Calendar OCTOBER

Introduction

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

Prototype

int OCTOBER

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

Click Source Link

Document

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

Usage

From source file:edu.ucsb.nceas.ezid.test.EZIDServiceTest.java

/** Generate a timestamp for use in IDs. */
public static String generateTimeString() {
    StringBuffer guid = new StringBuffer();

    // Create a calendar to get the date formatted properly
    String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);// w  w  w .j  a va2 s .c o m
    guid.append(calendar.get(Calendar.YEAR));
    guid.append(calendar.get(Calendar.DAY_OF_YEAR));
    guid.append(calendar.get(Calendar.HOUR_OF_DAY));
    guid.append(calendar.get(Calendar.MINUTE));
    guid.append(calendar.get(Calendar.SECOND));
    guid.append(calendar.get(Calendar.MILLISECOND));
    double random = Math.random();
    guid.append(random);

    return guid.toString();
}

From source file:com.delicious.deliciousfeeds4J.DeliciousUtilTest.java

@Test
public void testDeserializeUsersFromJson() throws Exception {

    final String SAMPLE_DATA = "[{\"dt\": \"2012-10-29T12:42:29Z\", \"user\": \"testuser\"}]";

    final Set<User> users = DeliciousUtil.deserializeUsersFromJson(SAMPLE_DATA);

    assertNotNull(users);/*from  w  ww  .j ava2s  .  c  o  m*/
    assertFalse(users.isEmpty());

    final User user = users.iterator().next();

    assertNotNull(user);
    assertEquals("testuser", user.getUser());

    final Calendar calendar = new GregorianCalendar();
    calendar.set(Calendar.DAY_OF_MONTH, 29);
    calendar.set(Calendar.MONTH, Calendar.OCTOBER);
    calendar.set(Calendar.YEAR, 2012);

    assertTrue(DateUtils.isSameDay(calendar.getTime(), user.getAddedDate()));
}

From source file:org.sakaiproject.util.CalendarUtil.java

void initDates() {
    Calendar calendarSunday = Calendar.getInstance();
    Calendar calendarMonday = Calendar.getInstance();
    Calendar calendarTuesday = Calendar.getInstance();
    Calendar calendarWednesday = Calendar.getInstance();
    Calendar calendarThursday = Calendar.getInstance();
    Calendar calendarFriday = Calendar.getInstance();
    Calendar calendarSaturday = Calendar.getInstance();

    calendarSunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    calendarMonday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    calendarTuesday.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
    calendarWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
    calendarThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
    calendarFriday.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
    calendarSaturday.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

    dateSunday = calendarSunday.getTime();
    dateMonday = calendarMonday.getTime();
    dateTuesday = calendarTuesday.getTime();
    dateWednesday = calendarWednesday.getTime();
    dateThursday = calendarThursday.getTime();
    dateFriday = calendarFriday.getTime();
    dateSaturday = calendarSaturday.getTime();

    Calendar calendarJanuary = Calendar.getInstance();
    Calendar calendarFebruary = Calendar.getInstance();
    Calendar calendarMarch = Calendar.getInstance();
    Calendar calendarApril = Calendar.getInstance();
    Calendar calendarMay = Calendar.getInstance();
    Calendar calendarJune = Calendar.getInstance();
    Calendar calendarJuly = Calendar.getInstance();
    Calendar calendarAugust = Calendar.getInstance();
    Calendar calendarSeptember = Calendar.getInstance();
    Calendar calendarOctober = Calendar.getInstance();
    Calendar calendarNovember = Calendar.getInstance();
    Calendar calendarDecember = Calendar.getInstance();

    calendarJanuary.set(Calendar.MONTH, Calendar.JANUARY);
    calendarFebruary.set(Calendar.MONTH, Calendar.FEBRUARY);
    calendarMarch.set(Calendar.MONTH, Calendar.MARCH);
    calendarApril.set(Calendar.MONTH, Calendar.APRIL);
    calendarMay.set(Calendar.MONTH, Calendar.MAY);
    calendarJune.set(Calendar.MONTH, Calendar.JUNE);
    calendarJuly.set(Calendar.MONTH, Calendar.JULY);
    calendarAugust.set(Calendar.MONTH, Calendar.AUGUST);
    calendarSeptember.set(Calendar.MONTH, Calendar.SEPTEMBER);
    calendarOctober.set(Calendar.MONTH, Calendar.OCTOBER);
    calendarNovember.set(Calendar.MONTH, Calendar.NOVEMBER);
    calendarDecember.set(Calendar.MONTH, Calendar.DECEMBER);

    dateJanuary = calendarJanuary.getTime();
    dateFebruary = calendarFebruary.getTime();
    dateMarch = calendarMarch.getTime();
    dateApril = calendarApril.getTime();
    dateMay = calendarMay.getTime();//from   w  w w.  j a va  2  s  .  c o m
    dateJune = calendarJune.getTime();
    dateJuly = calendarJuly.getTime();
    dateAugust = calendarAugust.getTime();
    dateSeptember = calendarSeptember.getTime();
    dateOctober = calendarOctober.getTime();
    dateNovember = calendarNovember.getTime();
    dateDecember = calendarDecember.getTime();

}

From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java

/**
 * @see PortletsController#getRadiologyOrdersByPatientQueryAndDateRange(String, Date, Date)
 * @verifies not populate model and view with table of orders if start date is after end date
 *///from  ww w.j  a  v  a 2s .  c  o m
@Test
public void ordersTable_shouldNotPopulateModelAndViewWithTableOfOrdersIfStartDateIsAfterEndDate()
        throws Exception {

    //given
    String patientQuery = "";
    Date startDate = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime();
    Date endDate = new GregorianCalendar(2001, Calendar.JANUARY, 01).getTime();

    ModelAndView mav = portletsController.getRadiologyOrdersByPatientQueryAndDateRange(patientQuery, startDate,
            endDate);
    assertThat(mav, is(notNullValue()));

    assertThat(mav.getModelMap(), hasKey("orderList"));
    List<RadiologyOrder> orderList = (List<RadiologyOrder>) mav.getModelMap().get("orderList");
    assertThat(orderList, is(notNullValue()));
    assertThat(orderList, is(empty()));

    assertThat(mav.getModelMap(), hasKey("exceptionText"));
    String exception = (String) mav.getModelMap().get("exceptionText");
    assertThat(exception, is(notNullValue()));
    assertThat(exception, is("radiology.crossDate"));
}

From source file:edu.northwestern.bioinformatics.studycalendar.dao.reporting.ScheduledActivitiesReportRowDaoTest.java

public void testSearchWithStopDateFilter_Neg() {
    MutableRange<Date> range = new MutableRange<Date>();
    range.setStop(DateUtils.createDate(2006, Calendar.OCTOBER, 25));
    filters.setActualActivityDate(range);
    assertSearchWithResults();/*from  w  ww. j  a  v a 2 s.  c  o  m*/
}

From source file:org.techytax.util.DateHelper.java

public static Date getLastDayOfFirstMonthOfNextQuarter(Date date) {
    int month = getMonth(date);
    int year = getYear(date);
    Calendar cal = new GregorianCalendar();
    cal.set(Calendar.YEAR, year);
    Date lastDay = null;//from  w w w. j  ava  2s .c  o  m
    switch (month) {
    case 0:
    case 1:
    case 2:
    case 3:
        cal.set(Calendar.MONTH, Calendar.APRIL);
        cal.set(Calendar.DAY_OF_MONTH, 30);
        lastDay = cal.getTime();
        break;
    case 4:
    case 5:
    case 6:
        cal.set(Calendar.MONTH, Calendar.JULY);
        cal.set(Calendar.DAY_OF_MONTH, 31);
        lastDay = cal.getTime();
        break;
    case 7:
    case 8:
    case 9:
        cal.set(Calendar.MONTH, Calendar.OCTOBER);
        cal.set(Calendar.DAY_OF_MONTH, 31);
        lastDay = cal.getTime();
        break;
    case 10:
    case 11:
        cal.add(Calendar.YEAR, 1);
        cal.set(Calendar.MONTH, Calendar.JANUARY);
        cal.set(Calendar.DAY_OF_MONTH, 31);
        lastDay = cal.getTime();
        break;
    default:
        break;
    }
    return lastDay;
}

From source file:org.openmrs.module.reporting.common.DateUtilTest.java

@Test
@Verifies(value = "should correctly handle daylight savings time", method = "getTimespan(Date,Date,null)")
public void getTimespan_shouldCorrectlyHandleDaylightSavingsTime() throws Exception {
    // USA has daylight saving time.
    // in 2009 DST started March 8 and ended November 1

    Calendar cal = new GregorianCalendar(Locale.US);
    cal.set(Calendar.YEAR, 2009);
    cal.set(Calendar.DAY_OF_MONTH, 25);

    cal.set(Calendar.MONTH, Calendar.FEBRUARY);
    Date feb25 = cal.getTime();/*from   w ww .  j  a  va 2 s.c om*/

    cal.set(Calendar.MONTH, Calendar.MARCH);
    Date mar25 = cal.getTime();

    cal.set(Calendar.MONTH, Calendar.APRIL);
    Date apr25 = cal.getTime();

    cal.set(Calendar.MONTH, Calendar.OCTOBER);
    Date oct25 = cal.getTime();

    cal.set(Calendar.MONTH, Calendar.NOVEMBER);
    Date nov25 = cal.getTime();

    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    Date dec25 = cal.getTime();

    testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(mar25, feb25));
    testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(apr25, mar25));
    testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(nov25, oct25));
    testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(dec25, nov25));
}

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

@Test
public void testCurrentYear() {
    FTPFileEntryParser parser = new FTPParserSelector().getParser("UNIX");

    FTPFile parsed;//  w  w w . java  2 s  . co m

    parsed = parser.parseFTPEntry("-rw-r--r--   1 20708    205             194 Oct 17 14:40 D3I0_805.fixlist");
    assertNotNull(parsed);
    assertTrue(parsed.isFile());
    assertNotNull(parsed.getTimestamp());
    assertEquals(Calendar.OCTOBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(17, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(14, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY));
    assertEquals(40, parsed.getTimestamp().get(Calendar.MINUTE));
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.DumpTestController.java

private Employee getEmployee() {

    Calendar c = Calendar.getInstance();
    c.set(1982, Calendar.MAY, 5);
    c = DateUtils.truncate(c, Calendar.DATE);
    Employee jdoe = new Employee("John", "Doe", 34523, c.getTime());
    jdoe.setFavoriteColors("blue", "green");
    jdoe.setSalary(65000);/* w ww. j  a v a  2s  .  c  om*/

    c.clear();
    c.set(1975, Calendar.OCTOBER, 25);
    c = DateUtils.truncate(c, Calendar.DATE);
    Employee jsmith = new Employee("Jane", "Smith", 78234, c.getTime());
    jsmith.setFavoriteColors("red", "orange");

    jdoe.setSupervisor(jsmith);

    return jdoe;
}

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  . j a va 2  s .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());
}