List of usage examples for java.sql Date Date
public Date(long date)
From source file:com.example.app.ui.university.FacultyEditor.java
/** * Save the faculty entity./*from w w w. ja v a2s.c o m*/ */ private void _saveFaculty() { String firstStr = _firstName.getText(); String lastStr = _lastName.getText(); String slugStr = (firstStr.charAt(0) + lastStr).toLowerCase(); _faculty = EntityRetriever.getInstance().reattachIfNecessary(_faculty); if (!firstStr.equals(_faculty.getFirstName()) || !lastStr.equals(_faculty.getLastName())) { _faculty.setFirstName(firstStr); _faculty.setLastName(lastStr); _faculty.setSlug(slugStr); } _faculty.setRankType((RankType) _jobGrade.getSelectedObject()); Date joinDate; if (null == _joinDate.getDate()) { joinDate = new Date(System.currentTimeMillis()); } else { joinDate = new Date(_joinDate.getDate().getTime()); } _faculty.setJoinDate(joinDate); if (!_searchArea.getText().equals(_faculty.getSearchArea())) _faculty.setSearchArea(_searchArea.getText()); _faculty.setSabbatical(_yesRadio.isSelected()); try { _facultyDAO.saveFaculty(_faculty); } catch (Exception e) { _logger.info("Save fail", e); } }
From source file:su90.mybatisdemo.dao.Job_HistoryMapperTest.java
@Test(groups = { "insert" }, enabled = false) public void testInsert() { Employee emp = employeesMapper.findById(167L); Department dept = departmentsMapper.findById(60L); Job job = jobsMapper.findById("IT_PROG"); try {/* ww w.j a va 2 s .c o m*/ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); java.util.Date start_util_date = formatter.parse("19900101071010"); java.util.Date end_util_date = new java.util.Date(); Job_History jh = new Job_History(emp, new Date(start_util_date.getTime()), new Date(end_util_date.getTime()), job, dept); job_HistoryMapper.insertOne(jh); Job_History search = job_HistoryMapper.findByIdRaw(167L, new Date(start_util_date.getTime())); List<Job_History> result = job_HistoryMapper.findByRawType(search); assertEquals(result.size(), 1); assertNotNull(result.get(0)); assertNotNull(result.get(0).getEmployee()); assertNotNull(result.get(0).getJob()); assertNotNull(result.get(0).getDepartment()); } catch (ParseException ex) { assertTrue(false); } }
From source file:gov.nih.nci.integration.caaers.CaAERSAdverseEventStrategyTest.java
/** * Tests Rollback for createAdverseEvent using the ServiceInvocationStrategy class * //from www .j a v a 2 s . com * @throws IntegrationException - IntegrationException * @throws JAXBException - JAXBException */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void createAERollback() throws IntegrationException, JAXBException { final Date stTime = new Date(new java.util.Date().getTime()); xsltTransformer.transform(null, null, null); EasyMock.expectLastCall().andAnswer(new IAnswer() { public Object answer() { // return the value to be returned by the method (null for void) return getAEXMLString(); } }); final ServiceInvocationMessage serviceInvocationMessage = prepareServiceInvocationMessage(REFMSGID, getAEInterimMessage(), stTime, caAERSAdverseEventServiceInvocationStrategy.getStrategyIdentifier()); final ServiceInvocationResult result = caAERSAdverseEventServiceInvocationStrategy .rollback(serviceInvocationMessage); Assert.assertNotNull(result); }
From source file:de.alpharogroup.message.system.service.MessagesBusinessServiceTest.java
@Test(enabled = false) public void testSaveMessageWithRecipients() { IMessageContentModel messageModel = new MessageContentModel(); ISendInformationModel sendInformationModel = new SendInformationModel(); messageModel.setContent("Hello guys,\n\nhow are you?\n\nCheers\n\nMichael"); messageModel.setSubject("Hi guys"); IBaseMessageModel model = new BaseMessageModel(); model.setMessageContentModel(messageModel); model.setSendInformationModel(sendInformationModel); model.setMessageState(MessageState.UNREPLIED); model.setMessageType(MessageType.MAIL); final Users sender = getUser("Michael", "Knight", "michael.knight@gmail.com", "knight"); final Set<Users> recipients = new HashSet<>(); final Users recipient = getUser("Anton", "Einstein", "anton.einstein@gmail.com", "einstein"); recipients.add(recipient);/*from ww w . j ava 2 s. com*/ model.getSendInformationModel().setRecipients(recipients); model.getSendInformationModel().setSender(sender); model.getSendInformationModel().setSentDate(new Date(System.currentTimeMillis())); final Messages message = messagesService.saveMessageWithRecipients(model); AssertJUnit.assertTrue(messagesService.exists(message.getId())); final Set<Users> r = messagesService.getRecipients(message); AssertJUnit.assertTrue(r != null && !r.isEmpty()); AssertJUnit.assertTrue(r.iterator().next().equals(recipient)); // Test the find reply messages... // Create a reply message... messageModel = new MessageContentModel(); sendInformationModel = new SendInformationModel(); messageModel.setContent("Hello Michael,\n\nim fine and you?\n\nCheers\n\nAnton"); messageModel.setSubject("Re:Hi guys"); model = new BaseMessageModel(); model.setMessageContentModel(messageModel); model.setSendInformationModel(sendInformationModel); model.setMessageState(MessageState.UNREPLIED); model.setMessageType(MessageType.REPLY); // clear recipients recipients.clear(); // its a reply so the sender is now the recipient... recipients.add(sender); model.getSendInformationModel().setRecipients(recipients); model.getSendInformationModel().setSender(recipient); model.getSendInformationModel().setSentDate(new Date(System.currentTimeMillis())); final Messages replyMessage = messagesService.saveMessageWithRecipients(model); replyMessage.setParent(message); messagesService.merge(replyMessage); final List<Messages> replies = messagesService.findReplyMessages(recipient); System.out.println(replies); }
From source file:gov.nih.nci.integration.invoker.CaTissueSpecimenStrategyTest.java
/** * Tests rollbackCreatedSpecimens using the ServiceInvocationStrategy class * /* www . ja v a2s . c o m*/ * @throws IntegrationException - IntegrationException * @throws JAXBException - JAXBException */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void rollbackCreatedSpecimens() throws IntegrationException, JAXBException { final Date stTime = new Date(new java.util.Date().getTime()); xsltTransformer.transform(null, null, null); EasyMock.expectLastCall().andAnswer(new IAnswer() { public Object answer() { return getSpecimenXMLStr(); } }).anyTimes(); final ServiceInvocationResult clientResult = new ServiceInvocationResult(); EasyMock.expect(caTissueSpecimenClient.rollbackCreatedSpecimens((String) EasyMock.anyObject())) .andReturn(clientResult); EasyMock.replay(caTissueSpecimenClient); final ServiceInvocationMessage serviceInvocationMessage = prepareServiceInvocationMessage(REFMSGID, getSpecimenXMLStr(), stTime, caTissueSpecimenStrategy.getStrategyIdentifier()); final ServiceInvocationResult strategyResult = caTissueSpecimenStrategy.rollback(serviceInvocationMessage); Assert.assertNotNull(strategyResult); }
From source file:at.create.android.ffc.domain.Contact.java
/** * @param bornOn/*from w ww. j a va 2 s. c om*/ */ public void setBornOn(String bornOn) { if (!TextUtils.isEmpty(bornOn)) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { this.bornOn = new Date(dateFormat.parse(bornOn).getTime()); } catch (ParseException e) { Log.e(TAG, "Can not parse born on date: \"" + bornOn + "\"", e); } } }
From source file:io.lightlink.oracle.AbstractOracleType.java
protected STRUCT createStruct(Connection con, Object value, String type) throws SQLException { if (value == null) return null; Map mapValue;//from w ww . j a v a 2s . c om if (value instanceof Map) { mapValue = (Map) value; mapValue = new CaseInsensitiveMap(mapValue); } else { // create a Map from bean Map map = new CaseInsensitiveMap(new BeanMap(value)); map.remove("class"); mapValue = map; } STRUCT struct; StructDescriptor structType = safeCreateStructureDescriptor(type, con); ResultSetMetaData stuctMeteData = structType.getMetaData(); List<Object> orderedValues = new ArrayList<Object>(); if (stuctMeteData.getColumnCount() == 1 && mapValue.size() == 1) { orderedValues.add(mapValue.values().iterator().next()); } else { for (int col = 1; col <= stuctMeteData.getColumnCount(); col++) { Object v = mapValue.get(stuctMeteData.getColumnName(col)); if (v == null) { v = mapValue.get(stuctMeteData.getColumnName(col).replaceAll("_", "")); } String typeName = stuctMeteData.getColumnTypeName(col); int columnType = stuctMeteData.getColumnType(col); if (columnType == OracleTypes.ARRAY) { v = createArray(con, v, typeName); } else if (columnType == OracleTypes.JAVA_STRUCT || columnType == OracleTypes.JAVA_OBJECT || columnType == OracleTypes.STRUCT) { v = createStruct(con, v, typeName); } orderedValues.add(v); } } Object[] values = orderedValues.toArray(); for (int j = 0; j < values.length; j++) { Object v = values[j]; if (v instanceof Long && stuctMeteData.getColumnTypeName(j + 1).equalsIgnoreCase("TIMESTAMP")) { values[j] = new Timestamp((Long) v); } else if (v instanceof Long && stuctMeteData.getColumnTypeName(j + 1).equalsIgnoreCase("DATE")) { values[j] = new Date((Long) v); } } struct = new STRUCT(structType, con, values); return struct; }
From source file:org.arasthel.almeribus.Principal.java
@Override public void onPostCreate(Bundle savedInstanceState) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); long ultimaActualizacion = sp.getLong("ultima_actualizacion", 0); Date fechaUltima = new Date(ultimaActualizacion); long nuevoTiempo = System.currentTimeMillis(); Date nuevaFecha = new Date(nuevoTiempo); necesitaActualizacion = false;// w ww .j a v a2s . co m if (nuevaFecha.getDay() != fechaUltima.getDay() || nuevaFecha.getMonth() != fechaUltima.getMonth() || nuevaFecha.getYear() != fechaUltima.getYear()) { necesitaActualizacion = true; } // We load the bus stop info from Surbus server cargarParadas(); if (savedInstanceState == null && !necesitaActualizacion && !loaded) { savedInstanceState = new Bundle(); savedInstanceState.putBoolean("SlidingActivityHelper.open", true); } super.onPostCreate(savedInstanceState); }
From source file:com.rsmart.kuali.kfs.cr.document.service.impl.GlTransactionServiceImpl.java
/** * Generate GlPendingTransaction/* www . j a va 2 s .c o m*/ * * @param paymentGroup * @param financialDocumentTypeCode * @param stale */ private void generateGlPendingTransaction(PaymentGroup paymentGroup, String financialDocumentTypeCode, boolean stale) { List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>(); for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) { accountListings.addAll(paymentDetail.getAccountDetail()); } GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(); for (PaymentAccountDetail paymentAccountDetail : accountListings) { GlPendingTransaction glPendingTransaction = new GlPendingTransaction(); glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter())); glPendingTransaction .setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode()); glPendingTransaction .setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode()); glPendingTransaction.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL); Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime()); glPendingTransaction.setTransactionDt(transactionTimestamp); AccountingPeriod fiscalPeriod = accountingPeriodService .getByDate(new java.sql.Date(transactionTimestamp.getTime())); glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear()); glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode()); glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr()); glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode()); glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString()); // Set doc type and origin code glPendingTransaction.setFinancialDocumentTypeCode(financialDocumentTypeCode); glPendingTransaction.setFsOriginCd(CRConstants.CR_FDOC_ORIGIN_CODE); String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT); String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE); String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA); // Use clearing parameters if stale String accountNbr = stale ? clAcct : paymentAccountDetail.getAccountNbr(); String finObjectCode = stale ? obCode : paymentAccountDetail.getFinObjectCode(); String finCoaCd = stale ? coaCode : paymentAccountDetail.getFinChartCode(); Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities(); if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) { OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class) .getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode()); glPendingTransaction.setAccountNumber(accountNbr); glPendingTransaction.setChartOfAccountsCode(finCoaCd); glPendingTransaction.setFinancialObjectCode( offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : finObjectCode); glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } else { glPendingTransaction.setAccountNumber(accountNbr); glPendingTransaction.setChartOfAccountsCode(finCoaCd); glPendingTransaction.setFinancialObjectCode(finObjectCode); glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode()); } glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode()); if (paymentAccountDetail.getAccountNetAmount().bigDecimalValue().signum() >= 0) { glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE); } else { glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE); } glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs()); String trnDesc; String payeeName = paymentGroup.getPayeeName(); trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40); String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr(); if (StringUtils.isNotBlank(poNbr)) { trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9)); } String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr(); if (StringUtils.isNotBlank(invoiceNbr)) { trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14)); } if (trnDesc.length() > 40) { trnDesc = trnDesc.substring(0, 40); } glPendingTransaction.setDescription(trnDesc); glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr()); glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId()); glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr()); // update the offset account if necessary SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction); this.businessObjectService.save(glPendingTransaction); sequenceHelper.increment(); } }
From source file:com.ewcms.content.resource.service.ResourceService.java
@Override public Resource update(Integer id, File file, String path, Resource.Type type) throws IOException { Resource resource = resourceDao.get(id); Assert.notNull(resource, "Resourc is not exist,id = " + id); FileUtils.copyFile(file, new File(resource.getPath())); if (type == Resource.Type.IMAGE) { if (resource.getPath().equals(resource.getThumbPath())) { String thumbUri = getThumbUri(resource.getUri()); String thumbPath = Resource.resourcePath(resource.getSite(), thumbUri); if (ImageUtil.compression(file.getPath(), thumbPath, 128, 128)) { resource.setThumbUri(thumbUri); }//from ww w . j a va2 s. com } else { if (!ImageUtil.compression(file.getPath(), resource.getThumbPath(), 128, 128)) { FileUtils.forceDeleteOnExit(new File(resource.getThumbPath())); resource.setThumbUri(resource.getUri()); } } } resource.setStatus(Status.NORMAL); resource.setUpdateTime(new Date(System.currentTimeMillis())); resource.setName(getFilename(path)); resourceDao.persist(resource); return resource; }