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:Main.java

public static int getDaysInMonth(int month, int year) {
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.MARCH:
    case Calendar.MAY:
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.OCTOBER:
    case Calendar.DECEMBER:
        return 31;
    case Calendar.APRIL:
    case Calendar.JUNE:
    case Calendar.SEPTEMBER:
    case Calendar.NOVEMBER:
        return 30;
    case Calendar.FEBRUARY:
        return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 29 : 28;
    default:// w  w w.  jav  a 2s .  c  o m
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:Main.java

public static int getDaysInMonth(int month, int year) {
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.MARCH:
    case Calendar.MAY:
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.OCTOBER:
    case Calendar.DECEMBER:
        return 31;
    case Calendar.APRIL:
    case Calendar.JUNE:
    case Calendar.SEPTEMBER:
    case Calendar.NOVEMBER:
        return 30;
    case Calendar.FEBRUARY:
        return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 28 : 29;
    default:/*  ww w  .java2  s.c om*/
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:org.jasig.schedassist.impl.relationship.advising.TermCalculator.java

/**
 * Calculate the term number for the specified date time (as a {@link Calendar}).
 * This uses a rough formula to determine Fall/Spring/Summer semesters:
 <pre>//  w  w w.  jav a  2s . c  om
 if the month is between January and May (inclusive), the term is Spring.
 if the month is between June and August (inclusive), the term is Summer.
 if the month is between September and December (inclusive), the term is Fall.
 </pre>
 *
 * This is only approximate.
 * 
 * @param calendar
 * @return
 */
public static String calculateTerm(final Calendar calendar) {
    StringBuilder term = new StringBuilder();

    int month = calendar.get(Calendar.MONTH);
    String monthDigit;
    if (month >= Calendar.JANUARY && month <= Calendar.MAY) {
        monthDigit = "4";
    } else if (month >= Calendar.JUNE && month <= Calendar.AUGUST) {
        monthDigit = "6";
    } else {
        monthDigit = "2";
    }

    int year = calendar.get(Calendar.YEAR);
    if ("2".equals(monthDigit)) {
        // increment year by one for fall semester
        year++;
    }

    String centuryDigit = "0";
    if (year >= 2000) {
        centuryDigit = "1";
    }

    int twoDigitYear = year % 100;
    String yearDigit = StringUtils.leftPad(Integer.toString(twoDigitYear), 2, "0");

    term.append(centuryDigit);
    term.append(yearDigit);
    term.append(monthDigit);
    return term.toString();
}

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

/**
 * http://trac.cyberduck.ch/ticket/2246/*from   ww  w  .ja  v  a 2  s .  co  m*/
 */
@Test
public void testParse() throws Exception {
    FTPFile parsed;

    parsed = parser.parseFTPEntry("drwxr-xr-x   7 ToysPKG  advertise   8192 Jun 24 11:58 Private Label Mock");
    assertNotNull(parsed);
    assertEquals(parsed.getName(), "Private Label Mock");
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals("ToysPKG", parsed.getUser());
    assertEquals("advertise", parsed.getGroup());
    assertEquals(8192, parsed.getSize());
    assertEquals(Calendar.JUNE, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(24, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));

    parsed = parser.parseFTPEntry(
            "-rw-r--r--   1 ToysPKG  advertise24809879 Jun 25 10:54 TRU-Warning Guide Master CD.sitx");
    assertNull(parsed);
}

From source file:net.audumla.astronomy.SeasonTest.java

@Test
public void testWinterStart() throws Exception {
    SeasonalEvent event = new SeasonalEvent(SeasonalEvent.WINTERSTART, Geolocation.newGeoLocation(30, 0, 0));
    Date et = event.calculateEventFrom(new Date());
    assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.DECEMBER;

    event = new SeasonalEvent(SeasonalEvent.WINTERSTART, Geolocation.newGeoLocation(-30, 0, 0));
    et = event.calculateEventFrom(new Date());
    assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.JUNE;
}

From source file:net.audumla.astronomy.SeasonTest.java

@Test
public void testSummerStart() throws Exception {
    SeasonalEvent event = new SeasonalEvent(SeasonalEvent.SUMMERSTART, Geolocation.newGeoLocation(30, 0, 0));
    Date et = event.calculateEventFrom(new Date());
    assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.JUNE;

    event = new SeasonalEvent(SeasonalEvent.SUMMERSTART, Geolocation.newGeoLocation(-30, 0, 0));
    et = event.calculateEventFrom(new Date());
    assert DateUtils.toCalendar(et).get(Calendar.MONTH) == Calendar.DECEMBER;
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBoltTest.java

@Test
public void testEnrichDataswift(@Mocked final LogRecord record) throws Exception {
    final Calendar calendar = Calendar.getInstance();
    calendar.clear();/*w  ww  . jav a 2  s.  c o  m*/
    calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
    calendar.set(2014, Calendar.JUNE, 10, 20, 22, 4);

    bolt.dateFields = Arrays.asList("interaction.created_at");
    bolt.dateFormat = "EEE, dd MMM yyyy HH:mm:ss Z";

    new Expectations() {
        {
            record.getValue(bolt.dateFields.get(0));
            result = "Tue, 10 Jun 2014 20:22:04 +0000";
            record.setDate(calendar.getTime());
        }
    };
    bolt.process(record);
}

From source file:com.cemeterylistingswebtest.test.services.approveDeceasedListingServiceTest.java

@Test
public void Test() {

    //deadRepo = ctx.getBean(RequiresApprovalDeceasedListingRepository.class);
    adserv = ctx.getBean(ApproveDeceasedListingService.class);
    repo = ctx.getBean(SubscriberRepository.class);
    repoList = ctx.getBean(RequiresApprovalDeceasedListingRepository.class);
    userRepo = ctx.getBean(UserRoleRepository.class);

    //Initialise date
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2010);
    calendar.set(Calendar.MONTH, Calendar.JUNE);
    calendar.set(Calendar.DATE, 14);

    java.sql.Date javaSqlDate = new java.sql.Date(calendar.getTime().getTime());

    //Initialise user role                
    UserRole userRole = new UserRole.Builder().setLevel(2).build();
    //Initialise subscriber
    Subscriber newSub = new Subscriber.Builder().setEmail("greaper@gmail.com").setFirstName("Grim")
            .setSurname("reaper").setPwd("souls").setUsername("greaper").setSubscriptionDate(javaSqlDate)
            .setUserRoleID(userRole).build();
    repo.save(newSub);/*from www.  j a v  a 2 s  . com*/
    subID = newSub.getSubscriberID();

    //Finally Initialise RequiresApprovalDeceasedListing
    RequiresApprovalDeceasedListing newListing = new RequiresApprovalDeceasedListing.Builder()
            .setFirstName("elizabeth").setSurname("willow").setMaidenName("charles").setGender("Female")
            .setDateOfBirth("16/06/1960").setDateOfDeath("14/011/2014")
            .setGraveInscription("lived long and prospered").setGraveNumber("2811")
            .setImageOfBurialSite("/images/003.jpg")

            .setSubscriberSubmitID(subID)
            //cemetery id

            //names

            .build();

    repoList.save(newListing);
    id = newListing.getRequiresApprovalDeceasedListingID();
    boolean approve = adserv.approveDeceasedListing(id);
    Assert.assertFalse(approve);
    repoList.delete(newListing);
    repo.delete(newSub);

}

From source file:one.GanttDemo1.java

/**
 * Creates a sample dataset for a Gantt chart.
 *
 * @return The dataset.//w  w w.j a  va 2 s . c o  m
 */
public static IntervalCategoryDataset createDataset() {

    final TaskSeries s1 = new TaskSeries("Scheduled");
    s1.add(new Task("Write Proposal",
            new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001))));
    s1.add(new Task("Obtain Approval",
            new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001))));
    s1.add(new Task("Requirements Analysis",
            new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001))));
    s1.add(new Task("Design Phase",
            new SimpleTimePeriod(date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001))));
    s1.add(new Task("Design Signoff",
            new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001))));
    s1.add(new Task("Alpha Implementation",
            new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001))));
    s1.add(new Task("Design Review",
            new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001))));
    s1.add(new Task("Revised Design Signoff",
            new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001))));
    s1.add(new Task("Beta Implementation",
            new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001))));
    s1.add(new Task("Testing",
            new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001))));
    s1.add(new Task("Final Implementation",
            new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001))));
    s1.add(new Task("Signoff",
            new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001))));
    s1.add(new Task("Database set up",
            new SimpleTimePeriod(date(15, Calendar.OCTOBER, 2001), date(30, Calendar.OCTOBER, 2001))));

    final TaskSeries s2 = new TaskSeries("Actual");
    s2.add(new Task("Write Proposal",
            new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001))));
    s2.add(new Task("Obtain Approval",
            new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001))));
    s2.add(new Task("Requirements Analysis",
            new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(15, Calendar.MAY, 2001))));
    s2.add(new Task("Design Phase",
            new SimpleTimePeriod(date(15, Calendar.MAY, 2001), date(17, Calendar.JUNE, 2001))));
    s2.add(new Task("Design Signoff",
            new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), date(30, Calendar.JUNE, 2001))));
    s2.add(new Task("Alpha Implementation",
            new SimpleTimePeriod(date(1, Calendar.JULY, 2001), date(12, Calendar.SEPTEMBER, 2001))));
    s2.add(new Task("Design Review",
            new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), date(22, Calendar.SEPTEMBER, 2001))));
    s2.add(new Task("Revised Design Signoff",
            new SimpleTimePeriod(date(25, Calendar.SEPTEMBER, 2001), date(27, Calendar.SEPTEMBER, 2001))));
    s2.add(new Task("Beta Implementation",
            new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), date(30, Calendar.OCTOBER, 2001))));
    s2.add(new Task("Testing",
            new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), date(17, Calendar.NOVEMBER, 2001))));
    s2.add(new Task("Final Implementation",
            new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), date(5, Calendar.DECEMBER, 2001))));
    s2.add(new Task("Signoff",
            new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), date(11, Calendar.DECEMBER, 2001))));

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

    return collection;
}

From source file:de.forsthaus.backend.dao.impl.ChartDataDAOImpl.java

@Override
public List<ChartData> getChartDataForCustomer(long kunId) {

    List<ChartData> result = new ArrayList<ChartData>();

    if (kunId == 20) {
        Calendar calendar = new GregorianCalendar();
        calendar.set(2009, Calendar.JANUARY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30)));
        calendar.set(2009, Calendar.FEBRUARY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(450.30)));
        calendar.set(2009, Calendar.MARCH, 15, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(820.10)));
        calendar.set(2009, Calendar.APRIL, 20, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(654.00)));
        calendar.set(2009, Calendar.MAY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30)));
        calendar.set(2009, Calendar.JUNE, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(520.30)));
        calendar.set(2009, Calendar.JULY, 22, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30)));
        calendar.set(2009, Calendar.AUGUST, 13, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(20.30)));
        calendar.set(2009, Calendar.SEPTEMBER, 6, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(480.30)));
        calendar.set(2009, Calendar.OCTOBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(520.30)));
        calendar.set(2009, Calendar.NOVEMBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.70)));
        calendar.set(2009, Calendar.DECEMBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(1220.90)));
    } else if (kunId == 21) {
        Calendar calendar = new GregorianCalendar();
        calendar.set(2009, Calendar.JANUARY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30)));
        calendar.set(2009, Calendar.FEBRUARY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(450.30)));
        calendar.set(2009, Calendar.MARCH, 15, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.10)));
        calendar.set(2009, Calendar.APRIL, 20, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(154.00)));
        calendar.set(2009, Calendar.MAY, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(320.30)));
        calendar.set(2009, Calendar.JUNE, 2, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(620.30)));
        calendar.set(2009, Calendar.JULY, 22, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(920.30)));
        calendar.set(2009, Calendar.AUGUST, 13, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(120.30)));
        calendar.set(2009, Calendar.SEPTEMBER, 6, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(680.30)));
        calendar.set(2009, Calendar.OCTOBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(580.30)));
        calendar.set(2009, Calendar.NOVEMBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(820.70)));
        calendar.set(2009, Calendar.DECEMBER, 26, 0, 0, 0);
        result.add(new ChartData(kunId, calendar.getTime(), new BigDecimal(220.90)));
    }//w  w w.  j  a  v a2 s .c o m

    return result;

}