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:com.clustercontrol.systemlog.bean.SyslogMessage.java

/**
 * ??//w  w w. ja  va2s  .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;
}

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

/**
 * This method is used for getting calendar number of month by month
 * description//from  w ww.  j av  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.delicious.deliciousfeeds4J.DeliciousUtilTest.java

@Test
public void testDeserializeBookmarksFromJson() throws Exception {

    final String SAMPLE_DATA = "[{\"a\": \"test123\", \"d\": \"Writing Reactive Apps with ReactiveMongo and Play\", "
            + "\"n\": \"\", \"u\": \"http://stephane.godbillon.com/2012/10/18/writing-a-simple-app-with-reactivemongo-and-play-framework-pt-1.html\","
            + " \"t\": [\"web\", \"programming\", \"mongodb\", \"scala\"], \"dt\": \"2012-10-22T13:40:31Z\", \"md5\": \"4967ef979fca2b4629c3d5ad70f83c01\"}]";

    final List<Bookmark> bookmarks = DeliciousUtil.deserializeBookmarksFromJson(SAMPLE_DATA);

    assertNotNull(bookmarks);//from w w  w  .j  ava2s.  c  om
    assertFalse(bookmarks.isEmpty());
    assertEquals(1, bookmarks.size());

    final Bookmark bookmark = bookmarks.iterator().next();

    assertEquals("test123", bookmark.getUser());
    assertEquals("Writing Reactive Apps with ReactiveMongo and Play", bookmark.getTitle());
    assertEquals("", bookmark.getDescription());
    assertEquals(
            "http://stephane.godbillon.com/2012/10/18/writing-a-simple-app-with-reactivemongo-and-play-framework-pt-1.html",
            bookmark.getUrl());
    assertNotNull(bookmark.getTags());
    assertTrue(bookmark.getTags().contains("web"));

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

    assertTrue(DateUtils.isSameDay(calendar.getTime(), bookmark.getLastUpdatedDate()));
}

From source file:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java

public static String generateYear() {
    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);//from  w ww. j a  va  2  s .  c o m
    guid.append(calendar.get(Calendar.YEAR));

    return guid.toString();
}

From source file:org.kuali.kfs.module.endow.businessobject.lookup.CalculateProcessDateUsingFrequencyCodeService.java

/**
 * This method will check the current month and set the calendar to that month
 * @param month month to set the calendar
 * @return calendar calendar is set to the month selected
 *//*  w  w w .j  av a 2 s .  c om*/
protected Calendar setCaledarWithMonth(String month, Date currentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    int calendarMonth = 1;

    if (EndowConstants.FrequencyMonths.JANUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JANUARY;
    } else if (EndowConstants.FrequencyMonths.FEBRUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.FEBRUARY;
    } else if (EndowConstants.FrequencyMonths.MARCH.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MARCH;
    } else if (EndowConstants.FrequencyMonths.APRIL.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.APRIL;
    } else if (EndowConstants.FrequencyMonths.MAY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MAY;
    } else if (EndowConstants.FrequencyMonths.JUNE.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JUNE;
    } else if (EndowConstants.FrequencyMonths.JULY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JULY;
    } else if (EndowConstants.FrequencyMonths.AUGUST.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.AUGUST;
    } else if (EndowConstants.FrequencyMonths.SEPTEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.SEPTEMBER;
    } else if (EndowConstants.FrequencyMonths.OCTOBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.OCTOBER;
    } else if (EndowConstants.FrequencyMonths.NOVEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.NOVEMBER;
    } else if (EndowConstants.FrequencyMonths.DECEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.DECEMBER;
    }

    calendar.set(Calendar.MONTH, calendarMonth);

    return calendar;
}

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;/*w w w.j  a v a2  s.c  o m*/

    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:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java

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);//  ww  w  .j  av a 2 s . com
    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:io.realm.RealmJsonTests.java

@Test
public void createObjectFromJson_dateAsStringTimeZone() throws JSONException {
    // Oct 03 2015 14:45.33
    JSONObject json = new JSONObject();
    json.put("columnDate", "/Date(1443854733376+0800)/");

    realm.beginTransaction();/*  w  ww  . ja v  a 2s  .com*/
    realm.createObjectFromJson(AllTypes.class, json);
    realm.commitTransaction();

    AllTypes obj = realm.allObjects(AllTypes.class).first();
    Calendar cal = GregorianCalendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("Australia/West"));
    cal.set(2015, Calendar.OCTOBER, 03, 14, 45, 33);
    cal.set(Calendar.MILLISECOND, 0);
    Date convDate = obj.getColumnDate();

    assertEquals(convDate.getTime(), cal.getTime().getTime());
}

From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java

public void shouldReturn1Month5Days11HoursTenMinutesTwentySecondsAndThreeMilliseconds() {
    Calendar cal = prepareCalendar(2008, Calendar.OCTOBER, 1, 0, 0, 0, 0);
    setEndTime(cal.getTimeInMillis());//  w w  w.j  av  a2s.c  om
    long monthInMillis = Constants.getActualMonthInMillis(cal);
    setStartTime(substractFromDate(endTime - monthInMillis, 5, 11, 10, 23, 3));
    expectedValue = messages.get("1Month5Days11Hours10Minutes23Seconds3Milliseconds");
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java

private String monthToString(int month, Locale locale) {
    switch (month) {

    case Calendar.JANUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Janeiro";
        }/*from   ww w  .  ja  va2s  . c  o  m*/
        return "January";
    case Calendar.FEBRUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Fevereiro";
        }
        return "February";
    case Calendar.MARCH:
        if (locale.getLanguage().equals("pt")) {
            return "Maro";
        }
        return "March";
    case Calendar.APRIL:
        if (locale.getLanguage().equals("pt")) {
            return "Abril";
        }
        return "April";
    case Calendar.MAY:
        if (locale.getLanguage().equals("pt")) {
            return "Maio";
        }
        return "May";
    case Calendar.JUNE:
        if (locale.getLanguage().equals("pt")) {
            return "Junho";
        }
        return "June";
    case Calendar.JULY:
        if (locale.getLanguage().equals("pt")) {
            return "Julho";
        }
        return "July";
    case Calendar.AUGUST:
        if (locale.getLanguage().equals("pt")) {
            return "Agosto";
        }
        return "August";
    case Calendar.SEPTEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Setembro";
        }
        return "September";
    case Calendar.OCTOBER:
        if (locale.getLanguage().equals("pt")) {
            return "Outubro";
        }
        return "October";
    case Calendar.NOVEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Novembro";
        }
        return "November";
    case Calendar.DECEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Dezembro";
        }
        return "December";
    case Calendar.UNDECIMBER:
        return "Undecember";
    default:
        return "Error";
    }
}