Example usage for java.util GregorianCalendar getTime

List of usage examples for java.util GregorianCalendar getTime

Introduction

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

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:org.opens.tgol.controller.PageListControllerTest.java

/**
 * /*from ww  w .j a v  a  2  s . c  o  m*/
 * @param isActSiteScope 
 */
private void setUpActDataService(boolean isActSiteScope) {

    mockGroupOfPagesScope = createMock(Scope.class);
    mockSiteScope = createMock(Scope.class);
    mockContract = createMock(Contract.class);
    Collection<Contract> contractSet = new HashSet<Contract>();
    contractSet.add(mockContract);

    mockActDataService = createMock(ActDataService.class);
    mockAct = createMock(Act.class);

    expect(mockActDataService.getActFromAudit(mockAudit)).andReturn(mockAct).anyTimes();

    expect(mockAct.getContract()).andReturn(mockContract).anyTimes();
    if (isActSiteScope) {
        expect(mockSiteScope.getCode()).andReturn(ScopeEnum.DOMAIN).anyTimes();
        expect(mockAct.getScope()).andReturn(mockSiteScope).anyTimes();
    } else {
        expect(mockGroupOfPagesScope.getCode()).andReturn(ScopeEnum.GROUPOFPAGES).anyTimes();
        expect(mockAct.getScope()).andReturn(mockGroupOfPagesScope).anyTimes();
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.set(2030, 01, 01);

    expect(mockContract.getEndDate()).andReturn(calendar.getTime()).anyTimes();

    expect(mockContract.getUser()).andReturn(mockUser).anyTimes();

    expect(mockContract.getLabel()).andReturn("CONTRACT LABEL").anyTimes();

    expect(mockContract.getId()).andReturn(Long.valueOf(1)).anyTimes();

    replay(mockActDataService);
    replay(mockAct);
    replay(mockContract);
    replay(mockSiteScope);
    replay(mockGroupOfPagesScope);

    instance.setActDataService(mockActDataService);
    AuditStatisticsFactory.getInstance().setActDataService(mockActDataService);
}

From source file:fr.univlorraine.ecandidat.controllers.DemoController.java

/**
 * @param ine/*  ww  w. j ava  2s .c om*/
 * @return un individu Apogee anonyme
 */
public WSIndividu recupInfoEtudiant(String ine) {
    WSIndividu ind = null;
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(1992, 2, 12);
    if (ine != null && ine.equals("000000000") || ine.equals("1111111111") || ine.equals("2222222222")
            || ine.equals("3333333333") || ine.equals("4444444444") || ine.equals("5555555555")
            || ine.equals("6666666666") || ine.equals("7777777777") || ine.equals("8888888888")
            || ine.equals("9999999999")) {
        String cpt = ine.substring(0, 1);
        ind = new WSIndividu(1, "1", "057", new BigDecimal(ine), ine, "A", "D", cal.getTime(), "NomPat-" + cpt,
                "NomUsu-" + cpt, "Prenom1-" + cpt, "Prenom2-" + cpt, "Metz", "100");
        ind.setAdresse(new WSAdresse(1, "57000", "57463", "100", "15 rue de Nancy", "Etage 1", "Porte droite",
                "0383542120", "0612356421"));
        ind.setBac(new WSBac(new Long(ine), "S", "057", "0573227Y", null, "2009", "O"));
        List<WSCursusInterne> listCursusInterne = new ArrayList<WSCursusInterne>();
        listCursusInterne.add(new WSCursusInterne("VET001-001", "License 1 - Droit", "2010", "AB", "1"));
        listCursusInterne.add(new WSCursusInterne("VET001-002", "License 2 - Droit", "2011", "P", "1"));
        listCursusInterne.add(new WSCursusInterne("VET001-003", "License 2 - Droit", "2012", "P", "1"));
        listCursusInterne.add(new WSCursusInterne("VET001-004", "Master 1 - Droit", "2013", "B", "1"));
        listCursusInterne.add(new WSCursusInterne("VET001-005", "Master 2 - Droit", "2014", "P", "1"));
        ind.setListCursusInterne(listCursusInterne);
    }
    return ind;
}

From source file:mekhq.Utilities.java

public static int getDiffPartialYears(Date date, GregorianCalendar b) {
    GregorianCalendar a = new GregorianCalendar();
    a.setTime(date);/*w  w  w  .  j  av  a2 s  .com*/
    int diff = b.get(GregorianCalendar.YEAR) - a.get(GregorianCalendar.YEAR);
    if (diff == 0 && countDaysBetween(a.getTime(), b.getTime()) > 0) {
        return 1;
    }
    return diff;
}

From source file:net.alexjf.tmm.fragments.ImmedTransactionEditorFragment.java

@Override
public void onTimeSet(TimePicker view, int hours, int minutes) {
    GregorianCalendar calendar = new GregorianCalendar(0, 0, 0, hours, minutes);
    executionTimeButton.setText(timeFormat.format(calendar.getTime()));
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public SynchronizedDescriptiveStatistics getDailyStats(Date startDate, Date endDate, Long hospital,
        String filter, boolean includeWeekends, boolean ptflag, boolean scheduledFlag) {
    SynchronizedDescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(endDate);//from   w  ww.  ja v a 2 s. c o m
    gc.add(Calendar.DATE, -1);
    List<Object[]> counts = getDailyCounts(startDate, gc.getTime(), hospital, filter, includeWeekends, ptflag,
            scheduledFlag);
    for (Object[] item : counts) {
        stats.addValue(((Long) item[1]).doubleValue());
    }
    return stats;
}

From source file:org.eurekastreams.server.persistence.TabGroupMapperTest.java

/**
 * Verify the configurable time window for permanent deletion of a Tab - for a tab that's still within the window.
 * //from   ww  w  .  j  a  v  a 2s . co  m
 * @throws TabDeletionException
 *             thrown on exception deleting the tab.
 */
@Test
public void testDeletedTabWithinWindowShouldRemainAfterAnotherDelete() throws TabDeletionException {
    final int undeleteTabWindowInMinutes = 110;
    final int minutesSinceTestTabWasDeleted = 100;

    // set the undelete tab window
    jpaTabGroupMapper.setUndeleteTabWindowInMinutes(undeleteTabWindowInMinutes);

    // set the date the tab was deleted
    GregorianCalendar tabDeletionDate = new GregorianCalendar();
    tabDeletionDate.add(Calendar.MINUTE, -minutesSinceTestTabWasDeleted);
    getEntityManager()
            .createQuery("update versioned Tab set " + "dateDeleted = :deletedTimestamp " + "where id = :tabId")
            .setParameter("deletedTimestamp", tabDeletionDate.getTime())
            .setParameter("tabId", fordsDeletedTabId).executeUpdate();

    // delete the active tab
    jpaTabGroupMapper.deleteTab(jpaTabMapper.findById(fordsFirstTabId));

    // make sure that the deleted tab is still available
    int resultCount = getEntityManager()
            .createQuery("select version from Tab where id = :tabId and deleted = true")
            .setParameter("tabId", fordsDeletedTabId).getResultList().size();

    assertEquals(
            "After deleting a Tab, the Tab that was deleted within the undo window should still be present.", 1,
            resultCount);
}

From source file:org.eurekastreams.server.persistence.TabGroupMapperTest.java

/**
 * Verify the configurable time window for permanent deletion of a Tab - for a tab that's outside the window.
 * //  w  w  w.j a va  2 s  . c o m
 * @throws TabDeletionException
 *             thrown on exception deleting the tab.
 */
@Test
public void testDeletedTabOutsideWindowShouldBePermanentlyDeletedAfterAnotherDelete()
        throws TabDeletionException {
    final int undeleteTabWindowInMinutes = 90;
    final int minutesSinceTestTabWasDeleted = 100;

    // set the undelete tab window
    jpaTabGroupMapper.setUndeleteTabWindowInMinutes(undeleteTabWindowInMinutes);

    // set the date the tab was deleted
    GregorianCalendar tabDeletionDate = new GregorianCalendar();
    tabDeletionDate.add(Calendar.MINUTE, -minutesSinceTestTabWasDeleted);
    getEntityManager()
            .createQuery("update versioned Tab set " + "dateDeleted = :deletedTimestamp " + "where id = :tabId")
            .setParameter("deletedTimestamp", tabDeletionDate.getTime())
            .setParameter("tabId", fordsDeletedTabId).executeUpdate();

    // delete the active tab
    jpaTabGroupMapper.deleteTab(jpaTabMapper.findById(fordsFirstTabId));

    // make sure that the deleted tab is still available
    int resultCount = getEntityManager()
            .createQuery("select version from Tab where id = :tabId and deleted = true")
            .setParameter("tabId", fordsDeletedTabId).getResultList().size();

    assertEquals("After deleting a Tab, the Tab that was deleted outside the undo "
            + "window should still be permanently deleted.", 0, resultCount);
}

From source file:org.asqatasun.webapp.controller.PageListControllerTest.java

/**
 * /*w  ww  .j  a va2 s.  c o  m*/
 * @param isActSiteScope 
 */
private void setUpActDataService(boolean isActSiteScope) {

    mockGroupOfPagesScope = createMock(Scope.class);
    mockSiteScope = createMock(Scope.class);
    mockContract = createMock(Contract.class);

    mockActDataService = createMock(ActDataService.class);
    mockAct = createMock(Act.class);

    expect(mockActDataService.getActFromAudit(mockAudit)).andReturn(mockAct).anyTimes();

    expect(mockAct.getContract()).andReturn(mockContract).anyTimes();
    if (isActSiteScope) {
        expect(mockSiteScope.getCode()).andReturn(ScopeEnum.DOMAIN).anyTimes();
        expect(mockAct.getScope()).andReturn(mockSiteScope).anyTimes();
    } else {
        expect(mockGroupOfPagesScope.getCode()).andReturn(ScopeEnum.GROUPOFPAGES).anyTimes();
        expect(mockAct.getScope()).andReturn(mockGroupOfPagesScope).anyTimes();
    }
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.set(2030, 01, 01);

    expect(mockContract.getEndDate()).andReturn(calendar.getTime()).anyTimes();

    expect(mockContract.getUser()).andReturn(mockUser).anyTimes();

    expect(mockContract.getLabel()).andReturn("CONTRACT LABEL").anyTimes();

    expect(mockContract.getId()).andReturn(Long.valueOf(1)).anyTimes();

    replay(mockActDataService);
    replay(mockAct);
    replay(mockContract);
    replay(mockSiteScope);
    replay(mockGroupOfPagesScope);

    instance.setActDataService(mockActDataService);
    AuditStatisticsFactory.getInstance().setActDataService(mockActDataService);
}

From source file:com.sapienter.jbilling.server.process.AgeingBL.java

/**
 * Goes over all the users that are not active, and calls age on them.
 * This doesn't discriminate over entities.
 *///w w  w.  j a  va  2s. com
public void reviewAll(Date today) throws NamingException, SessionInternalError, SQLException {
    // go over all the users already in the ageing system
    for (UserDTO userRow : new UserDAS().findAgeing()) {
        age(userRow, today);
    }

    // now go over the active users with payable invoices
    UserBL user = new UserBL();
    CachedRowSet usersSql;
    try {
        usersSql = user.findActiveWithOpenInvoices();
    } catch (Exception e) {
        // avoid further problems
        LOG.error("Exception finding users to age", e);
        return;
    }

    InvoiceBL invoiceBL = new InvoiceBL();

    while (usersSql.next()) {
        Integer userId = new Integer(usersSql.getInt(1));
        user.set(userId);
        UserDTO userRow = user.getEntity();
        // get the grace period for the entity of this user
        PreferenceBL prefs = new PreferenceBL();
        prefs.set(userRow.getEntity().getId(), Constants.PREFERENCE_GRACE_PERIOD);
        int gracePeriod = prefs.getInt();
        LOG.debug("Reviewing invoices of user:" + userRow.getUserId() + " grace: " + gracePeriod);
        // now go over this user's pending invoices
        for (Iterator it2 = invoiceBL.getHome().findProccesableByUser(userRow).iterator(); it2.hasNext();) {
            InvoiceDTO invoice = (InvoiceDTO) it2.next();
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTime(invoice.getDueDate());
            if (gracePeriod > 0) {
                cal.add(Calendar.DATE, gracePeriod);
            }

            if (userRow.getUserId().intValue() == 17) {
                LOG.debug("invoice " + invoice.getId() + " due+grace=" + cal.getTime() + " today=" + today
                        + " compare=" + (cal.getTime().compareTo(today)));
            }

            if (cal.getTime().compareTo(today) < 0) {
                // ok, this user has an overdue invoice
                age(userRow, today);
                break;
            }
        }
    }
}

From source file:net.acesinc.nifi.processors.security.ConvertSecurityMarkingAndAttrListIntoJson.java

/**
 * Builds the Map of attributes that should be included in the JSON that is
 * emitted from this process.// ww  w  .j  a v  a 2  s.c om
 *
 * @param ff
 * @param rawSecurityMarking
 * @param atrListForStringValues
 * @param atrListForIntValues
 * @param atrListForDoubleValues
 * @param atrListForLongEpochToGoToDateValues
 * @param secConfig
 * @return Map of values that are feed to a Jackson ObjectMapper
 * @throws java.io.IOException
 */
protected Map<String, Object> buildSecurityAttributesMapForFlowFileAndBringInFlowAttrs(FlowFile ff,
        String rawSecurityMarking, String atrListForStringValues, String atrListForIntValues,
        String atrListForDoubleValues, String atrListForLongEpochToGoToDateValues,
        FlowAttrSecurityConfig secConfig) throws IOException {
    final ComponentLog logger = getLogger();
    Map<String, Object> atsToWrite = new HashMap<>();

    //handle all the string values
    //If list of attributes specified get only those attributes. Otherwise write them all
    if (StringUtils.isNotBlank(atrListForStringValues)) {
        String[] ats = StringUtils.split(atrListForStringValues, AT_LIST_SEPARATOR);
        if (ats != null) {
            for (String str : ats) {
                String cleanStr = str.trim();
                String val = ff.getAttribute(cleanStr);
                if (val != null) {
                    atsToWrite.put(cleanStr, val);
                } else {
                    atsToWrite.put(cleanStr, "");
                }
            }
        }

    } else {
        atsToWrite.putAll(ff.getAttributes());
    }
    //handle all int values
    if (StringUtils.isNotBlank(atrListForIntValues)) {
        String[] ats = StringUtils.split(atrListForIntValues, AT_LIST_SEPARATOR);
        if (ats != null) {
            for (String str : ats) {
                String cleanStr = str.trim();
                String val = ff.getAttribute(cleanStr);
                if (val != null) {
                    atsToWrite.put(cleanStr, Integer.parseInt(val));
                } else {
                    atsToWrite.put(cleanStr, null);
                }
            }
        }
    }
    //handle all double values
    if (StringUtils.isNotBlank(atrListForDoubleValues)) {
        String[] ats = StringUtils.split(atrListForDoubleValues, AT_LIST_SEPARATOR);
        if (ats != null) {
            for (String str : ats) {
                String cleanStr = str.trim();
                String val = ff.getAttribute(cleanStr);
                if (val != null) {
                    atsToWrite.put(cleanStr, Double.parseDouble(val));
                } else {
                    atsToWrite.put(cleanStr, null);
                }
            }
        }
    }
    //handle all date values
    if (StringUtils.isNotBlank(atrListForLongEpochToGoToDateValues)) {
        String[] ats = StringUtils.split(atrListForLongEpochToGoToDateValues, AT_LIST_SEPARATOR);
        if (ats != null) {
            for (String str : ats) {
                String cleanStr = str.trim();
                String val = ff.getAttribute(cleanStr);
                if (val != null) {
                    long epochTime = Long.parseLong(val);
                    GregorianCalendar gcal = new GregorianCalendar();
                    gcal.setTimeZone(TimeZone.getTimeZone(MONGO_TIME_ZONE));
                    gcal.setTimeInMillis(epochTime);
                    SimpleDateFormat sdf = new SimpleDateFormat(MONGO_DATE_TEMPLATE);
                    String mongoDate = sdf.format(gcal.getTime());
                    //to Date
                    Map<String, String> isoDate = new HashMap<>();
                    isoDate.put("$date", mongoDate);
                    atsToWrite.put(cleanStr, isoDate);
                } else {
                    atsToWrite.put(cleanStr, null);
                }
            }
        }
    }

    //build the classification object for json
    if (StringUtils.isNotBlank(rawSecurityMarking)) {
        Classification classification = new Classification();
        String cleanRawMarking = rawSecurityMarking.trim();
        logger.debug("cleanRawMarking:=" + cleanRawMarking);
        List<String> levels = convertSecMarkingToLevelsFlowAttr(cleanRawMarking, secConfig);
        classification.setLevels(levels);
        List<String> convertedComps = convertSecMarkingToCompartmentsFlowAttr(cleanRawMarking, secConfig);
        classification.setCompartments(convertedComps);
        List<String> convertedRels = convertSecMarkingToReleasabilitiesFlowAttr(cleanRawMarking, secConfig);
        classification.setReleasabilities(convertedRels);
        List<String> convertedDissems = convertSecMarkingToDissemControlsFlowAttr(cleanRawMarking, secConfig);
        classification.setDisseminationControls(convertedDissems);
        atsToWrite.put("classification", classification);

    } else {
        //should not get here, but if we do, we need to throw illegal state as we should not be ingesting w/o classification, but instead force configuration changes
        throw new IllegalStateException(
                "This processor is reaching an illegal state.  Please adjust configuration for rawSecurityMarking to not be blank or null.");
    }
    return atsToWrite;
}