Example usage for java.util GregorianCalendar GregorianCalendar

List of usage examples for java.util GregorianCalendar GregorianCalendar

Introduction

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

Prototype

GregorianCalendar(TimeZone zone, Locale locale, boolean flag) 

Source Link

Document

Constructs an empty GregorianCalendar.

Usage

From source file:org.openmrs.contrib.metadatarepository.util.DateConverterTest.java

public void testConvertDateToString() throws Exception {
    final Calendar cal = new GregorianCalendar(2005, 0, 16);
    final String date = (String) converter.convert(String.class, cal.getTime());
    assertEquals(DateUtil.convertDateToString(cal.getTime()), date);
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield",
            xydataset, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15);
    xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime()));
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    if (xyitemrenderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer;
        xylineandshaperenderer.setBaseShapesVisible(true);
        xylineandshaperenderer.setBaseShapesFilled(true);
    }/*w  w w . j a  v a2  s .  c om*/
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    jfreechart.addSubtitle(new TextTitle("November 2005"));
    TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm");
    texttitle.setFont(new Font("Dialog", 0, 9));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);
    return jfreechart;
}

From source file:org.flowable.rest.service.api.history.HistoricTaskInstanceQueryResourceTest.java

/**
 * Test querying historic task instance. POST query/historic-task-instances
 *//* w  w w.ja va  2  s.  c om*/
@Deployment
public void testQueryTaskInstances() throws Exception {
    HashMap<String, Object> processVariables = new HashMap<String, Object>();
    processVariables.put("stringVar", "Azerty");
    processVariables.put("intVar", 67890);
    processVariables.put("booleanVar", false);

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess",
            "myBusinessKey", processVariables);
    processEngineConfiguration.getClock().setCurrentTime(new GregorianCalendar(2013, 0, 1).getTime());
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    Task finishedTaskProcess1 = task;
    taskService.complete(task.getId());
    processEngineConfiguration.getClock().setCurrentTime(null);
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.setVariableLocal(task.getId(), "local", "test");
    taskService.setOwner(task.getId(), "test");
    taskService.setDueDate(task.getId(), new GregorianCalendar(2013, 0, 1).getTime());

    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess",
            processVariables);
    Task task2 = taskService.createTaskQuery().processInstanceId(processInstance2.getId()).singleResult();

    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE_QUERY);

    // Process variables
    ObjectNode requestNode = objectMapper.createObjectNode();
    ArrayNode variableArray = objectMapper.createArrayNode();
    ObjectNode variableNode = objectMapper.createObjectNode();
    variableArray.add(variableNode);
    requestNode.set("processVariables", variableArray);

    variableNode.put("name", "stringVar");
    variableNode.put("value", "Azerty");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "intVar");
    variableNode.put("value", 67891);
    variableNode.put("operation", "lessThan");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "lessThan");
    assertResultsPresentInPostDataResponse(url, requestNode);

    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "lessThanOrEquals");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "intVar");
    variableNode.put("value", 67889);
    variableNode.put("operation", "greaterThan");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "greaterThan");
    assertResultsPresentInPostDataResponse(url, requestNode);

    variableNode.put("name", "intVar");
    variableNode.put("value", 67890);
    variableNode.put("operation", "greaterThanOrEquals");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "stringVar");
    variableNode.put("value", "Azer%");
    variableNode.put("operation", "like");
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    variableNode.put("name", "local");
    variableNode.put("value", "test");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    variableArray = objectMapper.createArrayNode();
    variableNode = objectMapper.createObjectNode();
    variableArray.add(variableNode);
    requestNode.set("taskVariables", variableArray);
    variableNode.put("name", "local");
    variableNode.put("value", "test");
    variableNode.put("operation", "equals");
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    assertResultsPresentInPostDataResponse(url, requestNode, 3, task.getId(), task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processInstanceId", processInstance.getId());
    assertResultsPresentInPostDataResponse(url, requestNode, 2, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processInstanceId", processInstance2.getId());
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskAssignee", "kermit");
    assertResultsPresentInPostDataResponse(url, requestNode, 2, task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskAssigneeLike", "%mit");
    assertResultsPresentInPostDataResponse(url, requestNode, 2, task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskAssignee", "fozzie");
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskOwner", "test");
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskOwnerLike", "t%");
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskInvolvedUser", "test");
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("dueDateAfter", dateFormat.format(new GregorianCalendar(2010, 0, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("dueDateAfter", dateFormat.format(new GregorianCalendar(2013, 4, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("dueDateBefore", dateFormat.format(new GregorianCalendar(2010, 0, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("dueDateBefore", dateFormat.format(new GregorianCalendar(2013, 4, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 1, task.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskCompletedAfter", dateFormat.format(new GregorianCalendar(2010, 0, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 1, finishedTaskProcess1.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskCompletedAfter", dateFormat.format(new GregorianCalendar(2013, 4, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskCompletedBefore", dateFormat.format(new GregorianCalendar(2010, 0, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskCompletedAfter", dateFormat.format(new GregorianCalendar(2010, 3, 1).getTime()));
    assertResultsPresentInPostDataResponse(url, requestNode, 1, finishedTaskProcess1.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processBusinessKey", "myBusinessKey");
    assertResultsPresentInPostDataResponse(url, requestNode, 2, task.getId(), finishedTaskProcess1.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processBusinessKeyLike", "myBusiness%");
    assertResultsPresentInPostDataResponse(url, requestNode, 2, task.getId(), finishedTaskProcess1.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processDefinitionKey", "someTaskProcess");
    assertResultsPresentInPostDataResponse(url, requestNode, 0);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processDefinitionKey", "oneTaskProcess");
    assertResultsPresentInPostDataResponse(url, requestNode, task.getId(), finishedTaskProcess1.getId(),
            task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processDefinitionKeyLike", "oneTask%");
    assertResultsPresentInPostDataResponse(url, requestNode, task.getId(), finishedTaskProcess1.getId(),
            task2.getId());

    requestNode = objectMapper.createObjectNode();
    requestNode.put("processDefinitionKeyLike", "some%");
    assertResultsPresentInPostDataResponse(url, requestNode);

    requestNode = objectMapper.createObjectNode();
    requestNode.put("taskDefinitionKey", "processTask");
    assertResultsPresentInPostDataResponse(url, requestNode, finishedTaskProcess1.getId(), task2.getId());
}