Example usage for java.util Calendar JUNE

List of usage examples for java.util Calendar JUNE

Introduction

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

Prototype

int JUNE

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

Click Source Link

Document

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

Usage

From source file:org.spring.data.gemfire.cache.SpringGemfireTemplateTests.java

@Test
public void query() {
    String query;/*from  ww  w  .j a  v a2s .c  o  m*/

    // METHOD 1 - the following OQL query syntax absolutely does not work for a peer application cache scenario;
    // developer must use METHOD 2
    if (System.getProperty("spring.profiles.active").contains("client")) {
        query = String.format(
                "SELECT * FROM %1$s c WHERE c.birthDate >= DATE '%2$s' and c.birthDate <= DATE '%3$s'",
                customersTemplate.getRegion().getFullPath(), format(createDate(1980, Calendar.JULY, 1)),
                format(createDate(1995, Calendar.JUNE, 30)));

        assertEquals(
                "SELECT * FROM /Customers c WHERE c.birthDate >= DATE '1980-07-01' and c.birthDate <= DATE '1995-06-30'",
                query);

    }
    // METHOD 2 use for peer application cache
    else {
        query = String.format("birthDate >= DATE '%1$s' and birthDate <= DATE '%2$s'",
                format(createDate(1980, Calendar.JULY, 1)), format(createDate(1995, Calendar.JUNE, 30)));

        assertEquals("birthDate >= DATE '1980-07-01' and birthDate <= DATE '1995-06-30'", query);

    }

    System.out.printf("GemFire OQL Query is (%1$s)", query);

    SelectResults<Customer> customerResults = customersTemplate.query(query);

    assertNotNull(customerResults);

    List<Customer> actualCustomers = customerResults.asList();

    assertNotNull(actualCustomers);
    assertFalse(actualCustomers.isEmpty());
    assertEquals(expectedCustomers.size(), actualCustomers.size());
    assertTrue(String.format("Expected (%1$s); But was (%2$s)", expectedCustomers, actualCustomers),
            actualCustomers.containsAll(expectedCustomers));
}

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();/* w  ww.  j  av  a2s.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:gxu.software_engineering.shen10.market.service.UserServiceTest.java

@Test
public void testSync() {
    Calendar c = Calendar.getInstance();
    c.set(2013, Calendar.JUNE, 20);
    List<User> users = userService.sync(c.getTimeInMillis(), 40);
    System.err.println(users.size());
    assertThat(users.size() > 4, is(true));
}

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);//ww  w .ja  v a  2s  . 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.richfaces.component.CalendarComponentTest.java

public void testPreloadRanges() throws Exception {
    UICalendar calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
    calendar.setLocale(Locale.FRENCH);
    Calendar calendarObject = Calendar.getInstance();
    calendarObject.clear();/*from w w w .  ja  v a2 s.c  o  m*/
    calendarObject.set(2007, Calendar.JUNE, 10);

    Calendar preloadRangeBegin = Calendar.getInstance();
    preloadRangeBegin.clear();
    preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
    assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
    assertEquals(Calendar.JUNE, preloadRangeBegin.get(Calendar.MONTH));
    assertEquals(1, preloadRangeBegin.get(Calendar.DATE));

    Calendar preloadRangeEnd = Calendar.getInstance();
    preloadRangeEnd.clear();
    preloadRangeEnd.setTime(calendar.getDefaultPreloadEnd(calendarObject.getTime()));
    assertEquals(2007, preloadRangeEnd.get(Calendar.YEAR));
    assertEquals(Calendar.JUNE, preloadRangeEnd.get(Calendar.MONTH));
    assertEquals(30, preloadRangeEnd.get(Calendar.DATE));

    calendarObject.set(2007, Calendar.JANUARY, 1);
    preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
    assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
    assertEquals(Calendar.JANUARY, preloadRangeBegin.get(Calendar.MONTH));
    assertEquals(1, preloadRangeBegin.get(Calendar.DATE));

    calendarObject.set(2007, Calendar.JUNE, 10);
    calendar.setLocale(Locale.US);

    preloadRangeBegin.setTime(calendar.getDefaultPreloadBegin(calendarObject.getTime()));
    assertEquals(2007, preloadRangeBegin.get(Calendar.YEAR));
    assertEquals(Calendar.JUNE, preloadRangeBegin.get(Calendar.MONTH));
    assertEquals(1, preloadRangeBegin.get(Calendar.DATE));

    preloadRangeEnd.setTime(calendar.getDefaultPreloadEnd(calendarObject.getTime()));
    assertEquals(2007, preloadRangeEnd.get(Calendar.YEAR));
    assertEquals(Calendar.JUNE, preloadRangeEnd.get(Calendar.MONTH));
    assertEquals(30, preloadRangeEnd.get(Calendar.DATE));
}

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.//from   ww w . j a v  a2s  . 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:gxu.software_engineering.shen10.market.service.ItemServiceTest.java

@Test
public void testSync() {
    Calendar c = Calendar.getInstance();
    c.set(2013, Calendar.JUNE, 24);
    List<Item> items = itemService.sync(c.getTimeInMillis(), 50);
    System.err.println(items.size());
    assertThat(items.size() > 1, is(true));
}

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 w w  .  ja va2 s  .com*/
 */
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:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testAddDays() {
    Calendar calend = Calendar.getInstance();
    calend.set(Calendar.DATE, 27);
    calend.set(Calendar.MONTH, Calendar.JUNE);
    calend.set(Calendar.YEAR, 2012);
    calend.setTimeZone(TimeZone.getTimeZone("GMT+01"));
    assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.WEDNESDAY));
    DateUtil.addDaysExceptWeekEnds(calend, 2);
    assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.FRIDAY));
    assertThat(calend.get(Calendar.DATE), is(29));
    assertThat(calend.get(Calendar.MONTH), is(Calendar.JUNE));
    assertThat(calend.get(Calendar.YEAR), is(2012));

    calend = Calendar.getInstance();
    calend.set(Calendar.DATE, 27);
    calend.set(Calendar.MONTH, Calendar.JUNE);
    calend.set(Calendar.YEAR, 2012);
    calend.setTimeZone(TimeZone.getTimeZone("GMT+01"));
    assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.WEDNESDAY));
    DateUtil.addDaysExceptWeekEnds(calend, 4);
    assertThat(calend.get(Calendar.DAY_OF_WEEK), is(Calendar.TUESDAY));
    assertThat(calend.get(Calendar.DATE), is(3));
    assertThat(calend.get(Calendar.MONTH), is(Calendar.JULY));
    assertThat(calend.get(Calendar.YEAR), is(2012));
}

From source file:fixio.fixprotocol.fields.FieldFactoryTest.java

@Test
public void testValueOfUtcTimestampWithMillis() throws Exception {
    String value = "19980604-08:03:31.537";
    UTCTimestampField field = FieldFactory.valueOf(FieldType.OrigTime.tag(), value.getBytes(US_ASCII));

    assertEquals("tagnum", FieldType.OrigTime.tag(), field.getTagNum());

    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    calendar.set(Calendar.YEAR, 1998);
    calendar.set(Calendar.MONTH, Calendar.JUNE);
    calendar.set(Calendar.DAY_OF_MONTH, 4);
    calendar.set(Calendar.HOUR_OF_DAY, 8);
    calendar.set(Calendar.MINUTE, 3);
    calendar.set(Calendar.SECOND, 31);
    calendar.set(Calendar.MILLISECOND, 537);
    long timeInMillis = calendar.getTimeInMillis();

    assertEquals("value", timeInMillis, field.getValue().longValue());
    assertEquals("value", timeInMillis, field.timestampMillis());
}