Example usage for java.util Calendar APRIL

List of usage examples for java.util Calendar APRIL

Introduction

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

Prototype

int APRIL

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

Click Source Link

Document

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

Usage

From source file:net.sf.sze.service.impl.common.SchulKalenderServiceImpl.java

/**
 * {@inheritDoc}//from  ww  w . j a v  a2s .c  o m
 */
@Override
public Calendar getLeavedSchoolDate(final Calendar currentDate) {
    final Calendar result = Calendar.getInstance();
    if (currentDate.get(Calendar.MONTH) >= Calendar.APRIL
            && currentDate.get(Calendar.MONTH) < Calendar.OCTOBER) {
        result.set(currentDate.get(Calendar.YEAR), Calendar.FEBRUARY, 1, 0, 0, 0);
    } else if (currentDate.get(Calendar.MONTH) < Calendar.APRIL) {
        result.set(currentDate.get(Calendar.YEAR) - 1, Calendar.AUGUST, 1, 0, 0, 0);
    } else {
        result.set(currentDate.get(Calendar.YEAR), Calendar.AUGUST, 1, 0, 0, 0);
    }
    result.set(Calendar.MILLISECOND, 0);
    return result;
}

From source file:test.GanttDemo1.java

/**
 * Creates a sample dataset for a Gantt chart.
 *
 * @return The dataset./* ww  w.j  a va 2  s.c  om*/
 */
public static IntervalCategoryDataset createDataset(ArrayList<proceso> lista_imprimir) {

    String nameProcess;
    TimePeriod periodProcess;

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

    for (int i = 0; i < lista_imprimir.size(); i++) {
        nameProcess = "Proceso " + lista_imprimir.get(i).getId_proceso();
        s1.add(new Task(nameProcess,
                new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001))));
    }

    //        s1.add(new Task("Proceso 1",
    //               new SimpleTimePeriod(date(1, Calendar.APRIL, 2001),
    //                                    date(5, Calendar.APRIL, 2001))));
    //        s1.add(new Task("Proceso 2",
    //               new SimpleTimePeriod(date(5, Calendar.APRIL, 2001),
    //                                    date(9, Calendar.APRIL, 2001))));
    //        s1.add(new Task("Proceso 3",
    //               new SimpleTimePeriod(date(9, Calendar.APRIL, 2001),
    //                                    date(15, Calendar.MAY, 2001))));

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

    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)));
    }//from  w ww .  j a v a2s .c  o  m

    return result;

}

From source file:simpleserver.bot.BotController.java

public void ready() {
    spawnAt(Calendar.APRIL, 1);
    spawnAt(Calendar.JUNE, 1);
    spawnAt(Calendar.OCTOBER, 31);
}

From source file:ubic.gemma.core.analysis.preprocess.batcheffects.BatchInfoPopulationServiceTest.java

@Test
public void testDatesToBatchB() {
    BatchInfoPopulationHelperServiceImpl ser = new BatchInfoPopulationHelperServiceImpl();
    Calendar cal = Calendar.getInstance();
    cal.set(2004, Calendar.APRIL, 10);
    Date d = cal.getTime();// w  ww  . ja  v a 2s . c om

    Collection<Date> dates = new HashSet<>();

    dates.add(d);

    dates.add(DateUtils.addSeconds(d, 3500));// first batch, all within two hours of each other.
    dates.add(DateUtils.addSeconds(d, 7000));// first batch, all within two hours of each other.
    dates.add(DateUtils.addSeconds(d, 8000));// first batch, all within two hours of each other.
    dates.add(DateUtils.addHours(d, 2226));// second batch, but singleton merged backwards

    dates.add(DateUtils.addHours(d, 11124));// third batch , but second was a singleton so we're only on #2.
    dates.add(DateUtils.addHours(d, 11125));// third batch, but gets merged in with second.
    dates.add(DateUtils.addHours(d, 11189)); // fourth batch, but gets merged in with second.

    Map<String, Collection<Date>> actual = ser.convertDatesToBatches(dates);

    /*
     * How many unique values?
     */
    Set<String> s = new HashSet<>(actual.keySet());
    assertEquals(2, s.size());

    this.debug(actual);
}

From source file:moviemanager.backend.RelationshipManagerTest.java

@Test
public void addPersonAsCast() {
    log.info("Testing adding person as cast...");
    String personName = "John Doe (personAsCast)";
    String movieTitle = "Cast Movie";

    // create movie
    Movie movie = new Movie();
    movie.setTitle(movieTitle);//from w  w  w.j a v a  2 s  .c o m
    movie.setYear(2000);
    movie.setLength(120);
    movieManager.createMovie(movie);
    assertNotNull(movie);

    // create person
    Calendar calendar = new GregorianCalendar(1987, Calendar.APRIL, 27);
    Person person = new Person(personName, calendar);
    personManager.createPerson(person);
    assertNotNull(person);

    // add to relationship dtb and check it was added
    relationManager.addPersonToRole(person, movie, Consts.CAST);
    assertTrue(relationManager.checkRole(person, movie, Consts.CAST));

    // check if person from relationship dtb is the same as person inserted
    List<Person> resultPerson = relationManager.personsOfMovie(movie);
    assertNotNull(resultPerson);
    assertEquals(resultPerson.get(0).getName(), personName);
    assertEquals(resultPerson.get(0), person);

    // check if movie from relationship dtb is the same as movie inserted
    List<Movie> resultMovie = relationManager.moviesOfPerson(person);
    assertNotNull(resultMovie);
    assertEquals(resultMovie.get(0).getTitle(), movieTitle);
    assertEquals(resultMovie.get(0), movie);
}

From source file:org.metawidget.swing.widgetprocessor.binding.beanutils.BeanUtilsBindingProcessorTest.java

public void testScalaBinding() throws Exception {

    // Model/*from w  w w.j av  a 2  s  .c o  m*/

    Date dateFirst = new GregorianCalendar(1975, Calendar.APRIL, 9).getTime();

    ScalaFoo scalaFoo = new ScalaFoo();
    scalaFoo.bar_$eq(dateFirst);
    ScalaFoo scalaFoo2 = new ScalaFoo();
    scalaFoo.nestedFoo = scalaFoo2;
    ScalaFoo scalaFoo3 = new ScalaFoo();
    scalaFoo2.nestedFoo = scalaFoo3;
    scalaFoo3.bar_$eq(new GregorianCalendar(1976, Calendar.MAY, 16).getTime());

    // BeanUtilsBinding

    ConvertUtils.register(new DateConverter(DATE_FORMAT), Date.class);

    // Inspect

    SwingMetawidget metawidget = new SwingMetawidget();
    metawidget.addWidgetProcessor(new BeanUtilsBindingProcessor(
            new BeanUtilsBindingProcessorConfig().setPropertyStyle(new ScalaPropertyStyle())));
    BaseObjectInspectorConfig config = new BaseObjectInspectorConfig()
            .setPropertyStyle(new ScalaPropertyStyle());
    metawidget.setInspector(new PropertyTypeInspector(config));
    metawidget.setToInspect(scalaFoo);

    // Loading

    JTextField textField = (JTextField) metawidget.getComponent(1);
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
    assertEquals(dateFormat.format(dateFirst), textField.getText());
    JLabel label = (JLabel) metawidget.getComponent(5);
    assertEquals("Not settable", label.getText());

    JTextField nestedTextField = (JTextField) ((SwingMetawidget) metawidget.getComponent(3)).getComponent(1);
    assertEquals("", nestedTextField.getText());

    JTextField nestedNestedTextField = (JTextField) ((SwingMetawidget) ((SwingMetawidget) metawidget
            .getComponent(3)).getComponent(3)).getComponent(1);
    assertEquals(dateFormat.format(scalaFoo3.bar()), nestedNestedTextField.getText());

    // Saving

    Date dateSecond = new GregorianCalendar(1976, Calendar.MAY, 10).getTime();
    textField.setText(dateFormat.format(dateSecond));
    nestedNestedTextField.setText(dateFormat.format(new GregorianCalendar(1977, Calendar.JUNE, 17).getTime()));
    metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).save(metawidget);

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(scalaFoo.bar());
    assertEquals(1976, calendar.get(Calendar.YEAR));
    assertEquals(null, scalaFoo2.bar());
    calendar.setTime(scalaFoo3.bar());
    assertEquals(1977, calendar.get(Calendar.YEAR));

    // Rebinding

    textField = (JTextField) metawidget.getComponent(1);
    assertEquals(dateFormat.format(dateSecond), textField.getText());

    scalaFoo.bar_$eq(dateFirst);
    metawidget.getWidgetProcessor(BeanUtilsBindingProcessor.class).rebind(scalaFoo, metawidget);

    textField = (JTextField) metawidget.getComponent(1);
    assertEquals(dateFormat.format(dateFirst), textField.getText());
}

From source file:util.MyUtils.java

public static String getMonthString(int month) {
    switch (month - 1) {
    case Calendar.JANUARY:
        return "Jan";
    case Calendar.FEBRUARY:
        return "Feb";
    case Calendar.MARCH:
        return "Mar";
    case Calendar.APRIL:
        return "Apr";
    case Calendar.MAY:
        return "May";
    case Calendar.JUNE:
        return "Jun";
    case Calendar.JULY:
        return "Jul";
    case Calendar.AUGUST:
        return "Aug";
    case Calendar.SEPTEMBER:
        return "Sep";
    case Calendar.OCTOBER:
        return "Oct";
    case Calendar.NOVEMBER:
        return "Nov";
    case Calendar.DECEMBER:
        return "Dec";
    }/*from w  w  w  .ja  v a 2s  .  c o m*/
    return "";
}

From source file:Negocio.Produccion.Planificacion.GanttDemo.java

/**
 * Creates a sample dataset for a Gantt chart.
 *
 * @return The dataset.//from  ww w.j a  va2  s .  c om
 */
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))));

    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:org.openmrs.module.radiology.hl7.message.RadiologyORMO01Test.java

@Before
public void runBeforeEachTest() throws Exception {

    patient = new Patient();
    patient.setPatientId(1);/* ww w .  ja  va 2s.com*/

    PatientIdentifierType patientIdentifierType = new PatientIdentifierType();
    patientIdentifierType.setPatientIdentifierTypeId(1);
    patientIdentifierType.setName("Test Identifier Type");
    patientIdentifierType.setDescription("Test description");
    PatientIdentifier patientIdentifier = new PatientIdentifier();
    patientIdentifier.setIdentifierType(patientIdentifierType);
    patientIdentifier.setIdentifier("100");
    patientIdentifier.setPreferred(true);
    Set<PatientIdentifier> patientIdentifiers = new HashSet<PatientIdentifier>();
    patientIdentifiers.add(patientIdentifier);
    patient.addIdentifiers(patientIdentifiers);

    patient.setGender("M");

    Set<PersonName> personNames = new HashSet<PersonName>();
    PersonName personName = new PersonName();
    personName.setFamilyName("Doe");
    personName.setGivenName("John");
    personName.setMiddleName("Francis");
    personNames.add(personName);
    patient.setNames(personNames);

    Calendar calendar = Calendar.getInstance();
    calendar.set(1950, Calendar.APRIL, 1, 0, 0, 0);
    patient.setBirthdate(calendar.getTime());

    radiologyOrder = new RadiologyOrder();
    radiologyOrder.setOrderId(20);

    Field orderNumber = Order.class.getDeclaredField("orderNumber");
    orderNumber.setAccessible(true);
    orderNumber.set(radiologyOrder, "ORD-" + radiologyOrder.getOrderId());

    radiologyOrder.setPatient(patient);
    calendar.set(2015, Calendar.FEBRUARY, 4, 14, 35, 0);
    radiologyOrder.setScheduledDate(calendar.getTime());
    radiologyOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
    radiologyOrder.setInstructions("CT ABDOMEN PANCREAS WITH IV CONTRAST");

    study = new Study();
    study.setStudyId(1);
    study.setStudyInstanceUid("1.2.826.0.1.3680043.8.2186.1.1");
    study.setModality(Modality.CT);
    radiologyOrder.setStudy(study);
}