Example usage for java.util Calendar SEPTEMBER

List of usage examples for java.util Calendar SEPTEMBER

Introduction

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

Prototype

int SEPTEMBER

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

Click Source Link

Document

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

Usage

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();// www.j  a  v  a 2  s  .  c  om
    dateJune = calendarJune.getTime();
    dateJuly = calendarJuly.getTime();
    dateAugust = calendarAugust.getTime();
    dateSeptember = calendarSeptember.getTime();
    dateOctober = calendarOctober.getTime();
    dateNovember = calendarNovember.getTime();
    dateDecember = calendarDecember.getTime();

}

From source file:com.espertech.esper.regression.pattern.TestCronParameter.java

public void testOperator() throws Exception {
    // Observer for last Sunday of month, 0 = Sunday
    int lastDayOfWeek = getLastDayOfWeekInMonth(0, 2007);
    calendar.set(2007, getCurrentMonth(2007), lastDayOfWeek, 8, 00, 00);
    printCurrentTime(calendar);/*w w  w.  j a v  a 2 s .  c o m*/
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, *, *, 0 last, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last day of current month
    calendar.set(2007, getCurrentMonth(2007), getLastDayOfMonth(2007), 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, last, *, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last day of Auguts 2007
    // For Java: January=0, February=1, March=2, April=3, May=4, June=5,
    //            July=6, August=7, September=8, November=9, October=10, December=11
    // For Esper: January=1, February=2, March=3, April=4, May=5, June=6,
    //            July=7, August=8, September=9, November=10, October=11, December=12
    calendar.set(2007, Calendar.AUGUST, 31, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, last, 8, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last day of February 2007
    calendar.set(2007, Calendar.FEBRUARY, 28, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, last, 2, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last day of week (Saturday)
    Calendar calendar = Calendar.getInstance();
    Date date = new Date();
    calendar.setTime(date);
    calendar.set(Calendar.MILLISECOND, 0);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, *, *, last, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last Friday of June
    calendar.set(2007, Calendar.JUNE, 29, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, *, 6, 5 last, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last weekday of the current month
    calendar.set(2007, getCurrentMonth(2007), getLastWeekDayOfMonth(null, 2007), 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, lastweekday, *, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last weekday of September 2007, it's Friday September 28th
    calendar.set(2007, Calendar.SEPTEMBER, 28, 10, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, lastweekday, 9, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last weekday of February, it's Wednesday February 28th
    calendar.set(2007, Calendar.FEBRUARY, 28, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, lastweekday, 2, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for nearest weekday for current month on the 10th
    calendar.set(2007, getCurrentMonth(2007), getLastWeekDayOfMonth(10, 2007), 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, 10 weekday, *, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for nearest weekday of September 1st (Saturday), it's Monday September 3rd (no "jump" over month)
    calendar.set(2007, Calendar.SEPTEMBER, 3, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, 1 weekday, 9, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for nearest weekday of September 30th (Sunday), it's Friday September 28th (no "jump" over month)
    calendar.set(2007, Calendar.SEPTEMBER, 28, 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, 30 weekday, 9, *, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();

    // Observer for last Friday of current month,
    // 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4= Thursday, 5=Friday, 6=Saturday
    calendar.set(2007, getCurrentMonth(2007), getLastDayOfWeekInMonth(5, 2007), 8, 00, 00);
    printCurrentTime(calendar);
    baseTime = calendar.getTimeInMillis();
    testData = getEventSet(baseTime, 1000 * 60 * 10);
    expressionText = "timer:at(*, *, *, *, 5 last, *)";
    testCase = new EventExpressionCase(expressionText);
    testCase.add("A1");
    runTestEvent();
}

From source file:org.andstatus.app.net.social.ConnectionPumpioTest.java

public void testGetTimeline() throws IOException {
    String sinceId = originUrl.toExternalForm() + "/activity/frefq3232sf";

    String jso = RawResourceUtils.getString(this.getInstrumentation().getContext(),
            org.andstatus.app.tests.R.raw.user_t131t_inbox);
    httpConnectionMock.setResponse(jso);

    List<MbTimelineItem> timeline = connection.getTimeline(ApiRoutineEnum.STATUSES_HOME_TIMELINE,
            new TimelinePosition(sinceId), 20, "acct:t131t@" + originUrl.getHost());
    assertNotNull("timeline returned", timeline);
    int size = 6;
    assertEquals("Number of items in the Timeline", size, timeline.size());

    int ind = 0;/*from   w w  w .jav  a2  s  .c  om*/
    assertEquals("Posting image", MbTimelineItem.ItemType.MESSAGE, timeline.get(ind).getType());
    MbMessage mbMessage = timeline.get(ind).mbMessage;
    assertTrue("Message body: '" + mbMessage.getBody() + "'",
            mbMessage.getBody().contains("Fantastic wheel stand"));
    assertEquals("Message sent date: " + mbMessage.sentDate,
            TestSuite.utcTime(2013, Calendar.SEPTEMBER, 13, 1, 8, 32).getTime(), mbMessage.sentDate);

    ind++;
    assertEquals("Other User", MbTimelineItem.ItemType.USER, timeline.get(ind).getType());
    MbUser mbUser = timeline.get(ind).mbUser;
    assertEquals("Other actor", "acct:jpope@io.jpope.org", mbUser.actor.oid);
    assertEquals("WebFinger ID", "jpope@io.jpope.org", mbUser.actor.getWebFingerId());
    assertEquals("Following", TriState.TRUE, mbUser.followedByActor);

    ind++;
    assertEquals("User", MbTimelineItem.ItemType.USER, timeline.get(ind).getType());
    mbUser = timeline.get(ind).mbUser;
    assertEquals("Url of the actor", "https://identi.ca/t131t", mbUser.actor.getUrl());
    assertEquals("WebFinger ID", "t131t@identi.ca", mbUser.actor.getWebFingerId());
    assertEquals("Following", TriState.TRUE, mbUser.followedByActor);
    assertEquals("Url of the user", "https://fmrl.me/grdryn", mbUser.getUrl());

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertEquals("Favorited by someone else", TriState.TRUE, mbMessage.favoritedByActor);
    assertEquals("Actor -someone else", "acct:jpope@io.jpope.org", mbMessage.actor.oid);
    assertTrue("Does not have a recipient", mbMessage.recipient == null);
    assertEquals("Url of the message", "https://fmrl.me/lostson/note/Dp-njbPQSiOfdclSOuAuFw", mbMessage.url);

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertTrue("Have a recipient", mbMessage.recipient != null);
    assertEquals("Directed to yvolk", "acct:yvolk@identi.ca", mbMessage.recipient.oid);

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertTrue("Is a reply", mbMessage.inReplyToMessage != null);
    assertEquals("Is a reply to this user", mbMessage.inReplyToMessage.sender.getUserName(),
            "jankusanagi@identi.ca");
}

From source file:netmason.support.graphics.GanttDisplay.java

/**
 * Creates a sample dataset for a Gantt chart, using sub-tasks. In general,
 * you won't hard-code the dataset in this way - it's done here so that the
 * demo is self-contained.// w  ww .  j a v  a  2  s .  c  o  m
 * 
 * @return The dataset.
 */
private IntervalCategoryDataset createSampleDataset() {

    final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001));
    t1.setPercentComplete(1.00);
    s1.add(t1);

    final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001));
    t2.setPercentComplete(1.00);
    s1.add(t2);

    // here is a task split into two subtasks...
    final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001),
            date(5, Calendar.MAY, 2001));
    final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001),
            date(25, Calendar.APRIL, 2001));
    st31.setPercentComplete(1.0);
    final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001));
    st32.setPercentComplete(1.0);
    t3.addSubtask(st31);
    t3.addSubtask(st32);
    s1.add(t3);

    // and another...
    final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001));
    final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001));
    st41.setPercentComplete(1.0);
    final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001));
    st42.setPercentComplete(1.0);
    final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001));
    st43.setPercentComplete(0.50);
    t4.addSubtask(st41);
    t4.addSubtask(st42);
    t4.addSubtask(st43);
    s1.add(t4);

    final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001));
    s1.add(t5);

    final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001),
            date(31, Calendar.JULY, 2001));
    t6.setPercentComplete(0.60);

    s1.add(t6);

    final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001));
    t7.setPercentComplete(0.0);
    s1.add(t7);

    final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001),
            date(10, Calendar.AUGUST, 2001));
    t8.setPercentComplete(0.0);
    s1.add(t8);

    final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001),
            date(12, Calendar.SEPTEMBER, 2001));
    t9.setPercentComplete(0.0);
    s1.add(t9);

    final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001));
    t10.setPercentComplete(0.0);
    s1.add(t10);

    final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001),
            date(15, Calendar.NOVEMBER, 2001));
    t11.setPercentComplete(0.0);
    s1.add(t11);

    final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001));
    t12.setPercentComplete(0.0);
    s1.add(t12);

    final TaskSeriesCollection collection = new TaskSeriesCollection();
    collection.add(s1);

    return collection;
}

From source file:org.jfree.chart.demo.GanttDemo2.java

/**
 * Creates a sample dataset for a Gantt chart, using sub-tasks.  In general, you won't 
 * hard-code the dataset in this way - it's done here so that the demo is self-contained.
 *
 * @return The dataset.//from  w  ww .  j  a  v  a  2s  .co m
 */
private IntervalCategoryDataset createSampleDataset() {

    final TaskSeries s1 = new TaskSeries("Scheduled");

    final Task t1 = new Task("Write Proposal", date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001));
    t1.setPercentComplete(1.00);
    s1.add(t1);

    final Task t2 = new Task("Obtain Approval", date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001));
    t2.setPercentComplete(1.00);
    s1.add(t2);

    // here is a task split into two subtasks...
    final Task t3 = new Task("Requirements Analysis", date(10, Calendar.APRIL, 2001),
            date(5, Calendar.MAY, 2001));
    final Task st31 = new Task("Requirements 1", date(10, Calendar.APRIL, 2001),
            date(25, Calendar.APRIL, 2001));
    st31.setPercentComplete(1.0);
    final Task st32 = new Task("Requirements 2", date(1, Calendar.MAY, 2001), date(5, Calendar.MAY, 2001));
    st32.setPercentComplete(1.0);
    t3.addSubtask(st31);
    t3.addSubtask(st32);
    s1.add(t3);

    // and another...
    final Task t4 = new Task("Design Phase", date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001));
    final Task st41 = new Task("Design 1", date(6, Calendar.MAY, 2001), date(10, Calendar.MAY, 2001));
    st41.setPercentComplete(1.0);
    final Task st42 = new Task("Design 2", date(15, Calendar.MAY, 2001), date(20, Calendar.MAY, 2001));
    st42.setPercentComplete(1.0);
    final Task st43 = new Task("Design 3", date(23, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001));
    st43.setPercentComplete(0.50);
    t4.addSubtask(st41);
    t4.addSubtask(st42);
    t4.addSubtask(st43);
    s1.add(t4);

    final Task t5 = new Task("Design Signoff", date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001));
    s1.add(t5);

    final Task t6 = new Task("Alpha Implementation", date(3, Calendar.JUNE, 2001),
            date(31, Calendar.JULY, 2001));
    t6.setPercentComplete(0.60);

    s1.add(t6);

    final Task t7 = new Task("Design Review", date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001));
    t7.setPercentComplete(0.0);
    s1.add(t7);

    final Task t8 = new Task("Revised Design Signoff", date(10, Calendar.AUGUST, 2001),
            date(10, Calendar.AUGUST, 2001));
    t8.setPercentComplete(0.0);
    s1.add(t8);

    final Task t9 = new Task("Beta Implementation", date(12, Calendar.AUGUST, 2001),
            date(12, Calendar.SEPTEMBER, 2001));
    t9.setPercentComplete(0.0);
    s1.add(t9);

    final Task t10 = new Task("Testing", date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001));
    t10.setPercentComplete(0.0);
    s1.add(t10);

    final Task t11 = new Task("Final Implementation", date(1, Calendar.NOVEMBER, 2001),
            date(15, Calendar.NOVEMBER, 2001));
    t11.setPercentComplete(0.0);
    s1.add(t11);

    final Task t12 = new Task("Signoff", date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001));
    t12.setPercentComplete(0.0);
    s1.add(t12);

    final TaskSeriesCollection collection = new TaskSeriesCollection();
    collection.add(s1);

    return collection;
}

From source file:ISO8601DateTimeFormat.java

/**
 * Write century, year, and months./*from  www.j av  a 2s.  co  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:org.andstatus.app.net.social.pumpio.ConnectionPumpioTest.java

public void testGetTimeline() throws IOException {
    String sinceId = originUrl.toExternalForm() + "/activity/frefq3232sf";

    String jso = RawResourceUtils.getString(this.getInstrumentation().getContext(),
            org.andstatus.app.tests.R.raw.user_t131t_inbox);
    httpConnectionMock.setResponse(jso);

    List<MbTimelineItem> timeline = connection.getTimeline(ApiRoutineEnum.STATUSES_HOME_TIMELINE,
            new TimelinePosition(sinceId), 20, "acct:t131t@" + originUrl.getHost());
    assertNotNull("timeline returned", timeline);
    int size = 6;
    assertEquals("Number of items in the Timeline", size, timeline.size());

    int ind = 0;//from   www .j av a 2 s .c  o m
    assertEquals("Posting image", MbTimelineItem.ItemType.MESSAGE, timeline.get(ind).getType());
    MbMessage mbMessage = timeline.get(ind).mbMessage;
    assertTrue("Message body: '" + mbMessage.getBody() + "'",
            mbMessage.getBody().contains("Fantastic wheel stand"));
    assertEquals("Message sent date: " + mbMessage.sentDate,
            TestSuite.utcTime(2013, Calendar.SEPTEMBER, 13, 1, 8, 32).getTime(), mbMessage.sentDate);
    assertEquals("Sender's oid", "acct:jpope@io.jpope.org", mbMessage.sender.oid);
    assertEquals("Sender's username", "jpope@io.jpope.org", mbMessage.sender.getUserName());
    assertEquals("Sender's Display name", "jpope", mbMessage.sender.getRealName());
    assertEquals("Sender's profile image URL", "https://io.jpope.org/uploads/jpope/2013/7/8/LPyLPw_thumb.png",
            mbMessage.sender.avatarUrl);
    assertEquals("Sender's profile URL", "https://io.jpope.org/jpope", mbMessage.sender.getProfileUrl());
    assertEquals("Sender's Homepage", "https://io.jpope.org/jpope", mbMessage.sender.getHomepage());
    assertEquals("Sender's WebFinger ID", "jpope@io.jpope.org", mbMessage.sender.getWebFingerId());
    assertEquals("Description", "Does the Pope shit in the woods?", mbMessage.sender.getDescription());
    assertEquals("Messages count", 0, mbMessage.sender.msgCount);
    assertEquals("Favorites count", 0, mbMessage.sender.favoritesCount);
    assertEquals("Following (friends) count", 0, mbMessage.sender.followingCount);
    assertEquals("Followers count", 0, mbMessage.sender.followersCount);
    assertEquals("Location", "/dev/null", mbMessage.sender.location);
    assertEquals("Created at", 0, mbMessage.sender.getCreatedDate());
    assertEquals("Updated at", connection.parseDate("2013-09-12T17:10:44Z"), mbMessage.sender.getUpdatedDate());

    ind++;
    assertEquals("Other User", MbTimelineItem.ItemType.USER, timeline.get(ind).getType());
    MbUser mbUser = timeline.get(ind).mbUser;
    assertEquals("Other actor", "acct:jpope@io.jpope.org", mbUser.actor.oid);
    assertEquals("WebFinger ID", "jpope@io.jpope.org", mbUser.actor.getWebFingerId());
    assertEquals("Following", TriState.TRUE, mbUser.followedByActor);

    ind++;
    assertEquals("User", MbTimelineItem.ItemType.USER, timeline.get(ind).getType());
    mbUser = timeline.get(ind).mbUser;
    assertEquals("Url of the actor", "https://identi.ca/t131t", mbUser.actor.getProfileUrl());
    assertEquals("WebFinger ID", "t131t@identi.ca", mbUser.actor.getWebFingerId());
    assertEquals("Following", TriState.TRUE, mbUser.followedByActor);
    assertEquals("Url of the user", "https://fmrl.me/grdryn", mbUser.getProfileUrl());

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertEquals("Favorited by someone else", TriState.TRUE, mbMessage.favoritedByActor);
    assertEquals("Actor -someone else", "acct:jpope@io.jpope.org", mbMessage.actor.oid);
    assertTrue("Does not have a recipient", mbMessage.recipient == null);
    assertEquals("Url of the message", "https://fmrl.me/lostson/note/Dp-njbPQSiOfdclSOuAuFw", mbMessage.url);

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertTrue("Have a recipient", mbMessage.recipient != null);
    assertEquals("Directed to yvolk", "acct:yvolk@identi.ca", mbMessage.recipient.oid);

    ind++;
    mbMessage = timeline.get(ind).mbMessage;
    assertEquals(mbMessage.isSubscribed(), TriState.UNKNOWN);
    assertTrue("Is a reply", mbMessage.inReplyToMessage != null);
    assertEquals("Is a reply to this user", mbMessage.inReplyToMessage.sender.getUserName(),
            "jankusanagi@identi.ca");
    assertEquals(mbMessage.inReplyToMessage.isSubscribed(), TriState.FALSE);
}

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

/**
 * This method is used for getting month long description
 * /* ww  w . jav a  2s .  c  om*/
 * @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:voldemort.scheduled.DataCleanupJobTest.java

public void testCleanupStartTime() {
    // Make sure the default is always the next day.
    GregorianCalendar cal = new GregorianCalendar();
    assertEquals("Default is not tomorrow", Utils.getDayOfTheWeekFromNow(1),
            (cal.get(Calendar.DAY_OF_WEEK) + 1) % 7);

    // When starting the server any day in the week from SUN to FRI and
    // targeting a saturday, should always start on the next saturday
    GregorianCalendar expectedStart = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 29, 0, 0, 0);
    Random rand = new Random();
    for (int day = Calendar.SUNDAY; day <= Calendar.FRIDAY; day++) {
        GregorianCalendar serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 22 + day,
                rand.nextInt(24), rand.nextInt(60), rand.nextInt(60));
        GregorianCalendar computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
        assertEquals(//from  ww  w . j av  a 2  s  . c o m
                "Expected :" + expectedStart.getTimeInMillis() + " Computed: "
                        + computedStart.getTimeInMillis(),
                expectedStart.getTimeInMillis(), computedStart.getTimeInMillis());
    }

    // Targeting saturday, 00:00 and starting on a friday 23:59:59 should
    // start the next saturday
    GregorianCalendar serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 28, 23, 59, 59);
    GregorianCalendar computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
    assertEquals(
            "Expected :" + expectedStart.getTimeInMillis() + " Computed: " + computedStart.getTimeInMillis(),
            expectedStart.getTimeInMillis(), computedStart.getTimeInMillis());

    // If we start past the start hour on the target day, it should start
    // the next week
    serverStartTime = TestUtils.getCalendar(2012, Calendar.SEPTEMBER, 29, 1, 0, 1);
    computedStart = Utils.getCalendarForNextRun(serverStartTime, Calendar.SATURDAY, 0);
    assertEquals(Calendar.SATURDAY, computedStart.get(Calendar.DAY_OF_WEEK));
    assertEquals(serverStartTime.get(Calendar.DAY_OF_YEAR) + 7, computedStart.get(Calendar.DAY_OF_YEAR));
}

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  ww  .j a v a2 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());
}