Example usage for java.sql Timestamp getTime

List of usage examples for java.sql Timestamp getTime

Introduction

In this page you can find the example usage for java.sql Timestamp getTime.

Prototype

public long getTime() 

Source Link

Document

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Timestamp object.

Usage

From source file:jp.co.ntts.vhut.logic.PrivateCloudLogic.java

@Override
public void updateStorageResource() {
    //??/* w  w w .java  2  s  .  co  m*/
    Integer size = 0;
    Storage storage = jdbcManager.from(Storage.class).id(cloudConfig.getRhevStorageId()).getSingleResult();
    if (storage != null) {
        size = storage.physicalSize;
    }
    //?
    List<StorageResource> toBeInsertList = new ArrayList<StorageResource>();
    List<StorageResource> toBeUpdateList = new ArrayList<StorageResource>();
    Timestamp currentDate = TimestampUtil.getCurrentDateAsTimestamp();
    Timestamp minDate = TimestampUtil.subtract(currentDate, 1, TimestampUtil.Unit.DAY);
    Timestamp maxDate = TimestampUtil.add(cloudConfig.getReservationEndTimeMax(), 1, TimestampUtil.Unit.DAY);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    Map<String, StorageResource> resourceMap = new HashMap<String, StorageResource>();
    //?
    List<StorageResource> oldResourceList = jdbcManager.from(StorageResource.class)
            .where(new SimpleWhere().eq(storageResource().storageId(), cloudConfig.getRhevStorageId())
                    .ge(storageResource().time(), minDate).le(storageResource().time(), maxDate))
            .getResultList();
    for (StorageResource oldResource : oldResourceList) {
        String key = dateFormat.format(oldResource.time);
        resourceMap.put(key, oldResource);
    }
    //??
    Timestamp targetDate = currentDate;
    while (targetDate.before(maxDate)) {
        String key = dateFormat.format(targetDate);
        StorageResource oldResource = resourceMap.get(key);
        if (oldResource == null) {
            //
            StorageResource newResource = new StorageResource();
            newResource.id = targetDate.getTime();
            newResource.storageMax = size;
            newResource.storageTerminablyUsed = 0;
            newResource.storageId = cloudConfig.getRhevStorageId();
            newResource.time = targetDate;
            toBeInsertList.add(newResource);
        } else {
            //
            oldResource.storageMax = size;
            toBeUpdateList.add(oldResource);
        }
        targetDate = TimestampUtil.add(targetDate, 1, TimestampUtil.Unit.DAY);
    }
    //??
    if (toBeInsertList.size() > 0) {
        jdbcManager.insertBatch(toBeInsertList).execute();
    }
    //??
    if (toBeUpdateList.size() > 0) {
        jdbcManager.updateBatch(toBeUpdateList).execute();
    }
}

From source file:gov.nih.nci.cadsr.sentinel.tool.AlertRec.java

/**
 * Copy a time stamp. This guarantees the time is preset so the copy matches
 * the original value.//ww  w .  j a  v  a2  s  .  com
 * 
 * @param v_
 *        The Timestamp to copy.
 * @return The new Timestamp.
 */
private Timestamp copy(Timestamp v_) {
    if (v_ == null)
        return null;
    return new Timestamp(v_.getTime());
}

From source file:jp.co.ntts.vhut.logic.PrivateCloudLogic.java

@Override
public void updateClusterResource() {
    //?CPU???//from  w  ww.j  av  a2 s . c o m
    Integer totalCpuCore = 0;
    Integer totalMemory = 0;
    List<Host> hosts = jdbcManager.from(Host.class).leftOuterJoin(host().conflict())
            .where(new SimpleWhere().eq(host().clusterId(), cloudConfig.getRhevClusterId())).getResultList();
    for (Host host : hosts) {
        if (host.conflict != null && host.conflict.detail.equals("Removed")) {
            continue;
        }
        totalCpuCore += host.cpuCore;
        totalMemory += host.memory;
    }
    //?
    List<ClusterResource> toBeInsertList = new ArrayList<ClusterResource>();
    List<ClusterResource> toBeUpdateList = new ArrayList<ClusterResource>();
    Timestamp currentDate = TimestampUtil.getCurrentDateAsTimestamp();
    Timestamp minDate = TimestampUtil.subtract(currentDate, 1, TimestampUtil.Unit.DAY);
    Timestamp maxDate = TimestampUtil.add(cloudConfig.getReservationEndTimeMax(), 1, TimestampUtil.Unit.DAY);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    Map<String, ClusterResource> resourceMap = new HashMap<String, ClusterResource>();
    //?
    List<ClusterResource> oldResourceList = jdbcManager.from(ClusterResource.class)
            .where(new SimpleWhere().eq(clusterResource().clusterId(), cloudConfig.getRhevClusterId())
                    .ge(clusterResource().time(), minDate).le(clusterResource().time(), maxDate))
            .getResultList();
    for (ClusterResource oldResource : oldResourceList) {
        String key = dateFormat.format(oldResource.time);
        resourceMap.put(key, oldResource);
    }
    //??
    Timestamp targetDate = currentDate;
    while (targetDate.before(maxDate)) {
        String key = dateFormat.format(targetDate);
        ClusterResource oldResource = resourceMap.get(key);
        if (oldResource == null) {
            //
            ClusterResource newResource = new ClusterResource();
            newResource.id = targetDate.getTime();
            newResource.cpuCoreMax = totalCpuCore;
            newResource.cpuCoreTerminablyUsed = 0;
            newResource.memoryMax = totalMemory;
            newResource.memoryTerminablyUsed = 0;
            newResource.clusterId = cloudConfig.getRhevClusterId();
            newResource.time = targetDate;
            toBeInsertList.add(newResource);
        } else {
            //
            oldResource.cpuCoreMax = totalCpuCore;
            oldResource.memoryMax = totalMemory;
            toBeUpdateList.add(oldResource);
        }
        targetDate = TimestampUtil.add(targetDate, 1, TimestampUtil.Unit.DAY);
    }
    //??
    if (toBeInsertList.size() > 0) {
        jdbcManager.insertBatch(toBeInsertList).execute();
    }
    //??
    if (toBeUpdateList.size() > 0) {
        jdbcManager.updateBatch(toBeUpdateList).execute();
    }
}

From source file:org.kuali.kfs.module.ar.service.impl.ContractsGrantsInvoiceCreateDocumentServiceImpl.java

/**
 * This method takes all the applicable attributes from the associated award object and sets those attributes into their
 * corresponding invoice attributes.//from w  ww .ja  v  a  2 s  .co  m
 *
 * @param award The associated award that the invoice will be linked to.
 * @param awardAccounts
 * @param document
 * @param accountDetails letter of credit details if we're creating via loc
 * @param locCreationType letter of credit creation type if we're creating via loc
 */
protected void populateInvoiceFromAward(ContractsAndGrantsBillingAward award,
        List<ContractsAndGrantsBillingAwardAccount> awardAccounts, ContractsGrantsInvoiceDocument document,
        List<ContractsGrantsLetterOfCreditReviewDetail> accountDetails, String locCreationType) {
    if (ObjectUtils.isNotNull(award)) {
        // Invoice General Detail section
        InvoiceGeneralDetail invoiceGeneralDetail = new InvoiceGeneralDetail();
        invoiceGeneralDetail.setDocumentNumber(document.getDocumentNumber());
        invoiceGeneralDetail.setProposalNumber(award.getProposalNumber());
        invoiceGeneralDetail.setAward(award);

        // Set the last Billed Date and Billing Period
        Timestamp ts = new Timestamp(new java.util.Date().getTime());
        java.sql.Date today = new java.sql.Date(ts.getTime());
        AccountingPeriod currPeriod = accountingPeriodService.getByDate(today);
        java.sql.Date[] pair = verifyBillingFrequencyService
                .getStartDateAndEndDateOfPreviousBillingPeriod(award, currPeriod);
        invoiceGeneralDetail.setBillingPeriod(pair[0] + " to " + pair[1]);
        invoiceGeneralDetail.setLastBilledDate(pair[1]);

        populateInvoiceDetailFromAward(invoiceGeneralDetail, award);
        document.setInvoiceGeneralDetail(invoiceGeneralDetail);
        // To set Bill by address identifier because it is a required field - set the value to 1 as it is never being used.
        document.setCustomerBillToAddressIdentifier(1);

        // Set Invoice due date to current date as it is required field and never used.
        document.setInvoiceDueDate(dateTimeService.getCurrentSqlDateMidnight());

        // copy award's customer address to invoice address details
        document.getInvoiceAddressDetails().clear();

        ContractsAndGrantsBillingAgency agency = award.getAgency();
        if (ObjectUtils.isNotNull(agency)) {
            final List<InvoiceAddressDetail> invoiceAddressDetails = buildInvoiceAddressDetailsFromAgency(
                    agency, document);
            document.getInvoiceAddressDetails().addAll(invoiceAddressDetails);
        }

        java.sql.Date invoiceDate = document.getInvoiceGeneralDetail().getLastBilledDate();
        if (document.getInvoiceGeneralDetail().getBillingFrequencyCode()
                .equalsIgnoreCase(ArConstants.MILESTONE_BILLING_SCHEDULE_CODE)) {// To check if award has milestones
            final List<Milestone> milestones = getContractsGrantsBillingUtilityService()
                    .getActiveMilestonesForProposalNumber(award.getProposalNumber());
            if (!CollectionUtils.isEmpty(milestones)) {
                // copy award milestones to invoice milestones
                document.getInvoiceMilestones().clear();
                final List<InvoiceMilestone> invoiceMilestones = buildInvoiceMilestones(milestones,
                        invoiceDate);
                document.getInvoiceMilestones().addAll(invoiceMilestones);
            }
        } else if (document.getInvoiceGeneralDetail().getBillingFrequencyCode()
                .equalsIgnoreCase(ArConstants.PREDETERMINED_BILLING_SCHEDULE_CODE)) {// To check if award has bills
            final List<Bill> bills = getContractsGrantsBillingUtilityService()
                    .getActiveBillsForProposalNumber(award.getProposalNumber());
            if (!CollectionUtils.isEmpty(bills)) {
                // copy award milestones to invoice milestones
                document.getInvoiceBills().clear();
                final List<InvoiceBill> invoiceBills = buildInvoiceBills(bills, invoiceDate);
                document.getInvoiceBills().addAll(invoiceBills);
            }
        }

        // copy award's accounts to invoice account details
        document.getAccountDetails().clear();
        final List<InvoiceAccountDetail> invoiceAccountDetails = new ArrayList<>();
        List<InvoiceDetailAccountObjectCode> invoiceDetailAccountObjectsCodes = new ArrayList<>();
        Map<String, KualiDecimal> budgetAmountsByCostCategory = new HashMap<>();

        Integer currentYear = getUniversityDateService().getCurrentFiscalYear();
        final boolean firstFiscalPeriod = isFirstFiscalPeriod();
        final Integer fiscalYear = firstFiscalPeriod
                && useTimeBasedBillingFrequency(document.getInvoiceGeneralDetail().getBillingFrequencyCode())
                        ? currentYear - 1
                        : currentYear;

        final SystemOptions systemOptions = optionsService.getOptions(fiscalYear);

        List<String> balanceTypeCodeList = new ArrayList<String>();
        balanceTypeCodeList.add(systemOptions.getBudgetCheckingBalanceTypeCd());
        balanceTypeCodeList.add(systemOptions.getActualFinancialBalanceTypeCd());
        for (ContractsAndGrantsBillingAwardAccount awardAccount : awardAccounts) {
            InvoiceAccountDetail invoiceAccountDetail = buildInvoiceAccountDetailForAwardAccount(award,
                    awardAccount, document.getDocumentNumber(), document.getInvoiceGeneralDetail());
            final ContractsGrantsLetterOfCreditReviewDetail locReviewDetail = retrieveMatchingLetterOfCreditReviewDetail(
                    awardAccount, accountDetails);

            List<Balance> glBalances = retrieveBalances(fiscalYear, awardAccount.getChartOfAccountsCode(),
                    awardAccount.getAccountNumber(), balanceTypeCodeList);
            KualiDecimal awardAccountBudgetAmount = KualiDecimal.ZERO;
            KualiDecimal balanceAmount = KualiDecimal.ZERO;
            KualiDecimal awardAccountCumulativeAmount = KualiDecimal.ZERO;
            for (Balance balance : glBalances) {
                if (!isBalanceCostShare(balance)) {
                    if (balance.getBalanceTypeCode()
                            .equalsIgnoreCase(systemOptions.getBudgetCheckingBalanceTypeCd())) {
                        awardAccountBudgetAmount = addBalanceToAwardAccountBudgetAmount(balance,
                                awardAccountBudgetAmount, firstFiscalPeriod);
                        updateCategoryBudgetAmountsByBalance(balance, budgetAmountsByCostCategory,
                                firstFiscalPeriod);
                    } else if (balance.getBalanceTypeCode()
                            .equalsIgnoreCase(systemOptions.getActualFinancialBalanceTypeCd())) {
                        awardAccountCumulativeAmount = addBalanceToAwardAccountCumulativeAmount(document,
                                balance, award, awardAccountCumulativeAmount, firstFiscalPeriod);
                        updateCategoryActualAmountsByBalance(document, balance, award,
                                invoiceDetailAccountObjectsCodes, firstFiscalPeriod);
                    }
                }
                invoiceAccountDetail.setTotalBudget(awardAccountBudgetAmount);
                invoiceAccountDetail.setCumulativeExpenditures(awardAccountCumulativeAmount);
            }
            invoiceAccountDetails.add(invoiceAccountDetail);
            if (!ObjectUtils.isNull(locReviewDetail)
                    && !locReviewDetail.getClaimOnCashBalance().negated()
                            .equals(locReviewDetail.getAmountToDraw())
                    && StringUtils.equalsIgnoreCase(award.getBillingFrequencyCode(),
                            ArConstants.LOC_BILLING_SCHEDULE_CODE)) {
                distributeAmountAmongAllAccountObjectCodes(document, awardAccount,
                        invoiceDetailAccountObjectsCodes, locReviewDetail);
            } else {
                updateInvoiceDetailAccountObjectCodesByBilledAmount(awardAccount,
                        invoiceDetailAccountObjectsCodes);
            }
        }
        document.getAccountDetails().addAll(invoiceAccountDetails);
        if (!document.getInvoiceGeneralDetail().getBillingFrequencyCode()
                .equalsIgnoreCase(ArConstants.MILESTONE_BILLING_SCHEDULE_CODE)
                && !document.getInvoiceGeneralDetail().getBillingFrequencyCode()
                        .equalsIgnoreCase(ArConstants.PREDETERMINED_BILLING_SCHEDULE_CODE)) {
            document.getInvoiceDetailAccountObjectCodes().addAll(invoiceDetailAccountObjectsCodes);
            List<AwardAccountObjectCodeTotalBilled> awardAccountObjectCodeTotalBilleds = getAwardAccountObjectCodeTotalBilledDao()
                    .getAwardAccountObjectCodeTotalBuildByProposalNumberAndAccount(awardAccounts);
            List<ContractsGrantsInvoiceDetail> invoiceDetails = generateValuesForCategories(
                    document.getDocumentNumber(), document.getInvoiceDetailAccountObjectCodes(),
                    budgetAmountsByCostCategory, awardAccountObjectCodeTotalBilleds);
            document.getInvoiceDetails().addAll(invoiceDetails);
        }
        // Set some basic values to invoice Document
        populateContractsGrantsInvoiceDocument(award, document, accountDetails, locCreationType);
    }
}

From source file:fr.paris.lutece.portal.web.user.AdminUserJspBean.java

/**
 * Update a user account life time//from w w w.j av a 2s. c o m
 * @param request The request
 * @return The Jsp URL of the process result
 */
public String reactivateAccount(HttpServletRequest request) {
    AdminUser user = AdminUserHome.findByPrimaryKey(AdminUserService.getAdminUser(request).getUserId());
    String strUrl = StringUtils.EMPTY;
    int nbDaysBeforeFirstAlert = AdminUserService
            .getIntegerSecurityParameter(PARAMETER_TIME_BEFORE_ALERT_ACCOUNT);
    Timestamp firstAlertMaxDate = new Timestamp(
            new java.util.Date().getTime() + DateUtil.convertDaysInMiliseconds(nbDaysBeforeFirstAlert));

    if (user.getAccountMaxValidDate() != null) {
        // If the account is close to expire but has not expired yet
        if ((user.getAccountMaxValidDate().getTime() < firstAlertMaxDate.getTime())
                && (user.getStatus() < AdminUser.EXPIRED_CODE)) {
            AdminUserService.updateUserExpirationDate(user);
        }

        strUrl = AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_ACCOUNT_REACTIVATED,
                AppPathService.getAdminMenuUrl(), AdminMessage.TYPE_INFO);
    } else {
        strUrl = AdminMessageService.getMessageUrl(request, PROPERTY_MESSAGE_NO_ACCOUNT_TO_REACTIVATED,
                AppPathService.getAdminMenuUrl(), AdminMessage.TYPE_ERROR);
    }

    return strUrl;
}

From source file:jp.co.ntts.vhut.logic.PrivateCloudLogic.java

@Override
public void updateVlanResources() {
    long count = jdbcManager.from(Network.class)
            .where(new SimpleWhere().ne(network().status(), NetworkStatus.RESERVED_BY_SYSTEM)).getCount();
    List<VlanResource> toBeInsertList = new ArrayList<VlanResource>();
    List<VlanResource> toBeUpdateList = new ArrayList<VlanResource>();
    Timestamp currentDate = TimestampUtil.getCurrentDateAsTimestamp();
    Timestamp minDate = TimestampUtil.subtract(currentDate, 1, TimestampUtil.Unit.DAY);
    Timestamp maxDate = TimestampUtil.add(cloudConfig.getReservationEndTimeMax(), 1, TimestampUtil.Unit.DAY);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    Map<String, VlanResource> resourceMap = new HashMap<String, VlanResource>();
    //?/*from   ww w .  j  av  a  2  s.  c  o  m*/
    List<VlanResource> oldResourceList = jdbcManager.from(VlanResource.class)
            .where(new SimpleWhere().eq(vlanResource().cloudId(), cloudId).ge(vlanResource().time(), minDate)
                    .le(vlanResource().time(), maxDate))
            .getResultList();
    for (VlanResource oldResource : oldResourceList) {
        String key = dateFormat.format(oldResource.time);
        resourceMap.put(key, oldResource);
    }
    //??
    Timestamp targetDate = currentDate;
    //        maxDate = TimestampUtil.add(maxDate, 1, TimestampUtil.Unit.DAY);
    while (targetDate.before(maxDate)) {
        String key = dateFormat.format(targetDate);
        VlanResource oldResource = resourceMap.get(key);
        if (oldResource == null) {
            //
            VlanResource newResource = new VlanResource();
            newResource.id = targetDate.getTime();
            newResource.vlanMax = (int) count;
            newResource.vlanTerminablyUsed = 0;
            newResource.cloudId = cloudId;
            newResource.time = targetDate;
            toBeInsertList.add(newResource);
        } else {
            //
            oldResource.vlanMax = (int) count;
            toBeUpdateList.add(oldResource);
        }
        targetDate = TimestampUtil.add(targetDate, 1, TimestampUtil.Unit.DAY);
    }
    //??
    if (toBeInsertList.size() > 0) {
        jdbcManager.insertBatch(toBeInsertList).execute();
    }
    //??
    if (toBeUpdateList.size() > 0) {
        jdbcManager.updateBatch(toBeUpdateList).execute();
    }
}

From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatImportHelper.java

private Object converDateTypes(Object val, HCatFieldSchema hfs) {
    HCatFieldSchema.Type hfsType = hfs.getType();
    Date d;//  w  w w.  j ava  2 s.  c o m
    Time t;
    Timestamp ts;
    if (val instanceof java.sql.Date) {
        d = (Date) val;
        if (hfsType == HCatFieldSchema.Type.DATE) {
            return d;
        } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) {
            return new Timestamp(d.getTime());
        } else if (hfsType == HCatFieldSchema.Type.BIGINT) {
            return (d.getTime());
        } else if (hfsType == HCatFieldSchema.Type.STRING) {
            return val.toString();
        } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
            VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
            HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength());
            return hvc;
        } else if (hfsType == HCatFieldSchema.Type.CHAR) {
            CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
            HiveChar hChar = new HiveChar(val.toString(), cti.getLength());
            return hChar;
        }
    } else if (val instanceof java.sql.Time) {
        t = (Time) val;
        if (hfsType == HCatFieldSchema.Type.DATE) {
            return new Date(t.getTime());
        } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) {
            return new Timestamp(t.getTime());
        } else if (hfsType == HCatFieldSchema.Type.BIGINT) {
            return ((Time) val).getTime();
        } else if (hfsType == HCatFieldSchema.Type.STRING) {
            return val.toString();
        } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
            VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
            HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength());
            return hvc;
        } else if (hfsType == HCatFieldSchema.Type.CHAR) {
            CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
            HiveChar hChar = new HiveChar(val.toString(), cti.getLength());
            return hChar;
        }
    } else if (val instanceof java.sql.Timestamp) {
        ts = (Timestamp) val;
        if (hfsType == HCatFieldSchema.Type.DATE) {
            return new Date(ts.getTime());
        } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) {
            return ts;
        } else if (hfsType == HCatFieldSchema.Type.BIGINT) {
            return ts.getTime();
        } else if (hfsType == HCatFieldSchema.Type.STRING) {
            return val.toString();
        } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
            VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
            HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength());
            return hvc;
        } else if (hfsType == HCatFieldSchema.Type.CHAR) {
            CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
            HiveChar hc = new HiveChar(val.toString(), cti.getLength());
            return hc;
        }
    }
    return null;
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

private void loadExceptions(Connection con, Calendar cal, Map<EventObmId, Event> eventById,
        AbstractSQLCollectionHelper<?> eventIds) throws SQLException {
    if (eventById.isEmpty()) {
        return;//from w  ww . j  av  a 2  s  .c o  m
    }
    String exceps = "SELECT " + EXCEPS_FIELDS
            + " FROM Event e LEFT JOIN EventException on event_id=eventexception_parent_id "
            + "WHERE event_id IN (" + eventIds.asPlaceHolders() + ") AND eventexception_child_id IS NULL";
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = con.prepareStatement(exceps);
        eventIds.insertValues(ps, 1);
        rs = ps.executeQuery();
        while (rs.next()) {
            EventObmId eventId = new EventObmId(rs.getInt(1));
            Event e = eventById.get(eventId);
            EventRecurrence er = e.getRecurrence();
            Timestamp t = rs.getTimestamp(2);
            if (t != null) {
                cal.setTimeInMillis(t.getTime());
                er.addException(cal.getTime());
            }
        }
    } finally {
        obmHelper.cleanup(null, ps, rs);
    }
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

private EventRecurrence eventRecurrenceFromCursor(Calendar cal, ResultSet evrs) throws SQLException {
    EventRecurrence er = new EventRecurrence();
    er.setKind(RecurrenceKind.valueOf(evrs.getString("event_repeatkind")));
    er.setDays(new RecurrenceDaysParser().parse(evrs.getString("event_repeatdays")));
    er.setFrequence(evrs.getInt("event_repeatfrequence"));
    Timestamp endRepeat = evrs.getTimestamp("event_endrepeat");
    if (endRepeat != null) {
        cal.setTimeInMillis(endRepeat.getTime());
        er.setEnd(cal.getTime());/* w w w.  jav  a2 s. c  o  m*/
    }
    return er;
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

@VisibleForTesting
Event eventFromCursor(Calendar cal, ResultSet evrs) throws SQLException {
    Event e = new Event();
    int id = evrs.getInt("event_id");
    e.setUid(new EventObmId(id));
    e.setEntityId(EntityId.valueOf(evrs.getInt("evententity_entity_id")));
    e.setTimeUpdate(JDBCUtils.getDate(evrs, "event_timeupdate"));
    e.setTimeCreate(JDBCUtils.getDate(evrs, "event_timecreate"));
    e.setTimezoneName(evrs.getString("event_timezone"));
    e.setType(EventType.valueOf(evrs.getString("event_type")));
    e.setExtId(new EventExtId(evrs.getString("event_ext_id")));
    e.setOpacity(EventOpacity.getValueOf(evrs.getString("event_opacity")));
    e.setCategory(evrs.getString("eventcategory1_label"));
    e.setTitle(evrs.getString("event_title"));
    e.setLocation(evrs.getString("event_location"));
    cal.setTimeInMillis(evrs.getTimestamp("event_date").getTime());
    e.setStartDate(cal.getTime());/*from w ww .  j a  v  a2 s  . c o  m*/
    e.setDuration(JDBCUtils.convertNegativeIntegerToZero(evrs, "event_duration"));
    e.setPriority(evrs.getInt("event_priority"));
    e.setPrivacy(EventPrivacy.valueOf(evrs.getInt("event_privacy")));
    e.setAllday(evrs.getBoolean("event_allday"));
    e.setDescription(evrs.getString("event_description"));
    e.setSequence(evrs.getInt("event_sequence"));
    e.setRecurrence(eventRecurrenceFromCursor(cal, evrs));

    String domainName = evrs.getString("domain_name");
    e.setOwner(evrs.getString("owner"));
    e.setOwnerEmail(getUserObmEmail(evrs, domainName));
    e.setOwnerDisplayName(getOwnerDisplayName(evrs));
    e.setCreatorEmail(getCreatorObmEmail(evrs, domainName));
    e.setCreatorDisplayName(getCreatorDisplayName(evrs));
    Timestamp recurrenceId = evrs.getTimestamp("recurrence_id");
    if (recurrenceId != null) {
        cal.setTimeInMillis(recurrenceId.getTime());
        e.setRecurrenceId(cal.getTime());
    }
    return e;
}