java.sql.Timestamp Java Examples
The following examples show how to use
java.sql.Timestamp.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostgreSQLCastTest.java From high-performance-java-persistence with Apache License 2.0 | 6 votes |
@Test public void testCastEscapeOperator() { doInJPA(entityManager -> { List<Post> posts = entityManager.createNativeQuery( "SELECT * " + "FROM post " + "WHERE " + " date_part('dow', created_on) = " + " date_part('dow', :datetime\\:\\:date)", Post.class) .setParameter("datetime", Timestamp.valueOf( LocalDateTime.now().with( TemporalAdjusters.next(DayOfWeek.MONDAY))) ) .getResultList(); assertEquals(1, posts.size()); assertEquals("High-Performance Java Persistence, Part 1", posts.get(0).getTitle()); }); }
Example #2
Source File: GenericNonAuditedTemporalDirector.java From reladomo with Apache License 2.0 | 6 votes |
public void incrementUntil(MithraDatedTransactionalObject mithraObject, TemporalContainer container, AttributeUpdateWrapper updateWrapper, Timestamp until) { checkInfinityDate(mithraObject); container.enrollInWrite(mithraObject.zGetCurrentData()); Cache cache = mithraObject.zGetCache(); MithraTransaction tx = MithraManagerProvider.getMithraManager().getCurrentTransaction(); Timestamp asOfDate = businessDateAttribute.timestampValueOf(mithraObject); Timestamp fromDate = this.getBusinessFromDateForBusinessDate(asOfDate); Timestamp endDate = getBusinessFromDateForBusinessDate(until); InternalList inTxObjects = this.sortByBusinessFrom(container.getObjectsForRange(mithraObject, fromDate, endDate)); incrementMultipleWrappersUntil(inTxObjects, fromDate, endDate, cache, tx, new AttributeUpdateWrapper[] { updateWrapper} , container); mithraObject.zClearTxData(); }
Example #3
Source File: TestPaperAction.java From SmartEducation with Apache License 2.0 | 6 votes |
public String appStuTestPaper() throws Exception{ Map<String, Object> map=new HashMap<String, Object>(); Class_ classFind=classService.findById(classId); if(classFind==null){ map.put("name", "noClass"); } else{ Timestamp nowTime=new Timestamp(new Date().getTime()); List<TestPaper> testPaperList=testPaperService.findByClass(classFind,nowTime); if(testPaperList.size()<1){ map.put("name", "noTestPaper"); } else{ ClassPropertyFilter.ListTestPaperFilter(map, testPaperList); map.put("name", "success"); } } JsonUtil.toJson(ServletActionContext.getResponse(), map); return null; }
Example #4
Source File: MessageQueueForm.java From rice with Educational Community License v2.0 | 6 votes |
/** * Convert the specified input object into an output object of the * specified type. * * @param type Data type to which this value should be converted * @param value The input value to be converted * * @exception org.apache.commons.beanutils.ConversionException if conversion cannot be performed * successfully */ public Object convert(Class type, Object value) { if (value == null) { if (useDefault) { return (defaultValue); } else { throw new ConversionException("No value specified"); } } if (value instanceof Timestamp) { return (value); } try { return (Timestamp.valueOf(value.toString())); } catch (Exception e) { if (useDefault) { return (defaultValue); } else { throw new ConversionException(e); } } }
Example #5
Source File: TestAggregatePrimitiveBeanListWithHavingClause.java From reladomo with Apache License 2.0 | 5 votes |
public void testTimestampHavingLessThanForPrimitiveBeanList() throws ParseException { Timestamp ts = new Timestamp(timestampFormat.parse("2004-02-13 00:00:00.0").getTime()); Timestamp ts3 = new Timestamp(timestampFormat.parse("2004-02-12 01:00:00.0").getTime()); Timestamp ts4 = new Timestamp(timestampFormat.parse("2004-02-12 02:00:00.0").getTime()); Operation op = SaleFinder.all(); AggregateBeanList<PrimitiveAggregateBean> aggregateBeanList = new AggregateBeanList<PrimitiveAggregateBean>(op, PrimitiveAggregateBean.class); aggregateBeanList.addAggregateAttribute("maxSaleDate", SaleFinder.saleDate().max()); aggregateBeanList.addGroupBy("id", SaleFinder.sellerId()); aggregateBeanList.setHavingOperation(SaleFinder.saleDate().max().lessThan(ts)); assertEquals(2, aggregateBeanList.size()); for (PrimitiveAggregateBean data : aggregateBeanList) { if (data.getId() == 3) { assertEquals(ts3, data.getMaxSaleDate()); } else if (data.getId() == 4) { assertEquals(ts4, data.getMaxSaleDate()); } else { fail("Invalid seller id"); } } }
Example #6
Source File: DBQueryUtil.java From kardio with Apache License 2.0 | 5 votes |
/** * Update the tps_service table with latest tps values. * */ public static void updateTpsService(final int envId, int componentId, float tpsVaule, float latencyValue){ Session session = HibernateConfig.getSessionFactory().getCurrentSession(); Transaction txn = session.beginTransaction(); Query query = session.createQuery(HQLConstants.UPDATE_TPS_SERVICE_DETAILS); query.setFloat("tpsVaule", tpsVaule); query.setFloat("latencyValue", latencyValue); query.setTimestamp("lastUpdateDate", new java.sql.Timestamp(System.currentTimeMillis())); query.setLong("compId", componentId); query.setLong("environmentId", envId); query.executeUpdate(); txn.commit(); }
Example #7
Source File: TradeBuyOrdersDMLTxStmt.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
protected boolean insertToDerbyTable(Connection conn, int oid, int cid, int sid, int qty, String status, Timestamp time, BigDecimal bid) throws SQLException{ PreparedStatement stmt = getStmt(conn, insert); int tid = getMyTid(); int count = -1; Log.getLogWriter().info("Insert into derby, myTid is " + tid); try { count = insertToTable(stmt, oid, cid, sid, qty, status, time, bid, tid); Log.getLogWriter().info("derby inserts " + count + " record"); } catch (SQLException se) { if (!SQLHelper.checkDerbyException(conn, se)) return false; //for retry else throw se; } return true; }
Example #8
Source File: CacheLoaderManagerImpl.java From reladomo with Apache License 2.0 | 5 votes |
@Override public void loadDependentObjectsFor(List ownerObjects, List<Timestamp> businessDates, Timestamp loadEndTime, CacheLoaderMonitor monitor) { if (ownerObjects != null && !ownerObjects.isEmpty()) { CacheLoaderContext context = new CacheLoaderContext(this, businessDates); context.setQualifiedLoadContext(new QualifiedByOwnerObjectListLoadContext(ownerObjects)); context.execute(monitor); } }
Example #9
Source File: TestPostgresGeneralTestCases.java From reladomo with Apache License 2.0 | 5 votes |
public void testRetrieveOneRowUsingTimestampInOperation() throws ParseException { Operation op = AllTypesFinder.timestampValue().eq(new Timestamp(timestampFormat.parse("2007-01-01 01:01:01.999").getTime())); String sql = "select " + getAllTypesColumns() + " from public.ALL_TYPES where TIMESTAMP_COL = '01-JAN-07 01:01:01.999'"; validateMithraResult(op, sql); }
Example #10
Source File: DateRangeTest.java From ApprovalTests.Java with Apache License 2.0 | 5 votes |
@Test public void testFilter() throws Exception { DateRange range = new DateRange(quickDate(20), quickDate(40)); Timestamp dates[] = {quickDate(50), quickDate(40), quickDate(30), quickDate(20), quickDate(10)}; Approvals.verifyAll("Dates", Query.where(dates, d -> range.contains(d))); }
Example #11
Source File: StaffServiceImpl.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected StaffAddressOutVO handleAddStaffAddress( AuthenticationVO auth, StaffAddressInVO newStaffAddress) throws Exception { checkStaffAddressInput(newStaffAddress); StaffAddressDao addressDao = this.getStaffAddressDao(); StaffAddress address = addressDao.staffAddressInVOToEntity(newStaffAddress); Timestamp now = new Timestamp(System.currentTimeMillis()); User user = CoreUtil.getUser(); CoreUtil.modifyVersion(address, now, user); address = addressDao.create(address); StaffAddressOutVO result = addressDao.toStaffAddressOutVO(address); logSystemMessage(address.getStaff(), result.getStaff(), now, user, SystemMessageCodes.STAFF_ADDRESS_CREATED, result, null, this.getJournalEntryDao()); return result; }
Example #12
Source File: GsonBuilder.java From letv with Apache License 2.0 | 5 votes |
private void addTypeAdaptersForDate(String datePattern, int dateStyle, int timeStyle, List<TypeAdapterFactory> factories) { DefaultDateTypeAdapter dateTypeAdapter; if (datePattern != null && !"".equals(datePattern.trim())) { dateTypeAdapter = new DefaultDateTypeAdapter(datePattern); } else if (dateStyle != 2 && timeStyle != 2) { dateTypeAdapter = new DefaultDateTypeAdapter(dateStyle, timeStyle); } else { return; } factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Date.class), dateTypeAdapter)); factories.add(TreeTypeAdapter.newFactory(TypeToken.get(Timestamp.class), dateTypeAdapter)); factories.add(TreeTypeAdapter.newFactory(TypeToken.get(java.sql.Date.class), dateTypeAdapter)); }
Example #13
Source File: JavatimeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void print(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); System.out.printf("ldt:ts %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, %d/%d, nano:[%d/%d]%n", zdt.getYear(), ts.getYear() + 1900, zdt.getMonthValue(), ts.getMonth() + 1, zdt.getDayOfMonth(), ts.getDate(), zdt.getHour(), ts.getHours(), zdt.getMinute(), ts.getMinutes(), zdt.getSecond(), ts.getSeconds(), zdt.getNano(), ts.getNanos()); }
Example #14
Source File: EntityAddressBase.java From rice with Educational Community License v2.0 | 5 votes |
public void setValidatedDate(DateTime validatedDate) { if ( validatedDate != null ) { this.validatedDate = new Timestamp(validatedDate.getMillis()); } else { this.validatedDate = null; } }
Example #15
Source File: AlpineQueryManager.java From Alpine with Apache License 2.0 | 5 votes |
/** * Creates a new EventServiceLog. This method will automatically determine * if the subscriber is an implementation of {@link LoggableSubscriber} and * if so, will log the event. If not, then nothing will be logged and this * method will return null. * @param clazz the class of the subscriber task that handles the event * @return a new EventServiceLog */ public EventServiceLog createEventServiceLog(Class<? extends Subscriber> clazz) { if (LoggableSubscriber.class.isAssignableFrom(clazz)) { pm.currentTransaction().begin(); final EventServiceLog log = new EventServiceLog(); log.setSubscriberClass(clazz.getCanonicalName()); log.setStarted(new Timestamp(new Date().getTime())); pm.makePersistent(log); pm.currentTransaction().commit(); return getObjectById(EventServiceLog.class, log.getId()); } return null; }
Example #16
Source File: TaskListServiceImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void setItemComplete(Long taskListItemUid, Long userId, Long sessionId) { TaskListItemVisitLog log = taskListItemVisitDao.getTaskListItemLog(taskListItemUid, userId); if (log == null) { log = new TaskListItemVisitLog(); TaskListItem item = taskListItemDao.getByUid(taskListItemUid); log.setTaskListItem(item); TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, sessionId); log.setUser(user); log.setSessionId(sessionId); log.setAccessDate(new Timestamp(new Date().getTime())); } log.setComplete(true); taskListItemVisitDao.saveObject(log); }
Example #17
Source File: TestOracleGeneralTestCases.java From reladomo with Apache License 2.0 | 5 votes |
public void testRetrieveOneRowUsingTimestampInOperation() throws ParseException { Operation op = AllTypesFinder.timestampValue().eq(new Timestamp(timestampFormat.parse("2007-01-01 01:01:01.999").getTime())); String sql = "select * from " + getSchemaName() + ".ALL_TYPES where TIMESTAMP_COL = '01-JAN-07 01:01:01.999'"; validateMithraResult(op, sql); }
Example #18
Source File: KuduCatalogTest.java From bahir-flink with Apache License 2.0 | 5 votes |
private void validateManyTypes(String tableName) throws Exception { KuduTable kuduTable = harness.getClient().openTable(tableName); Schema schema = kuduTable.getSchema(); assertEquals(Type.STRING, schema.getColumn("first").getType()); assertEquals(Type.BOOL, schema.getColumn("second").getType()); assertEquals(Type.BINARY, schema.getColumn("third").getType()); assertEquals(Type.INT8, schema.getColumn("fourth").getType()); assertEquals(Type.INT16, schema.getColumn("fifth").getType()); assertEquals(Type.INT32, schema.getColumn("sixth").getType()); assertEquals(Type.INT64, schema.getColumn("seventh").getType()); assertEquals(Type.FLOAT, schema.getColumn("eighth").getType()); assertEquals(Type.DOUBLE, schema.getColumn("ninth").getType()); assertEquals(Type.UNIXTIME_MICROS, schema.getColumn("tenth").getType()); KuduScanner scanner = harness.getClient().newScannerBuilder(kuduTable).build(); List<RowResult> rows = new ArrayList<>(); scanner.forEach(rows::add); assertEquals(1, rows.size()); assertEquals("f", rows.get(0).getString(0)); assertEquals(false, rows.get(0).getBoolean(1)); assertEquals(ByteBuffer.wrap("bbbb".getBytes()), rows.get(0).getBinary(2)); assertEquals(12, rows.get(0).getByte(3)); assertEquals(34, rows.get(0).getShort(4)); assertEquals(56, rows.get(0).getInt(5)); assertEquals(78, rows.get(0).getLong(6)); assertEquals(3.14, rows.get(0).getFloat(7), 0.01); assertEquals(1.2345, rows.get(0).getDouble(8), 0.0001); assertEquals(Timestamp.valueOf("2020-04-15 12:34:56.123"), rows.get(0).getTimestamp(9)); }
Example #19
Source File: UomWorker.java From scipio-erp with Apache License 2.0 | 4 votes |
/** * SCIPIO: Returns Uom records of the requested type, but only those which have at least one * conversion record in the system. Used to prevent listing completely inconvertible Uom records * in the UI. * <p> * TODO: this is slow; should optimize somehow... * * @param asTarget ternary Boolean value: true means match only convertible-to Uoms, false means convertible-from, and null means both */ public static List<GenericValue> getConvertibleUoms(Delegator delegator, LocalDispatcher dispatcher, Boolean asTarget, Map<String, ?> uomLookupFields, List<String> orderBy, boolean filterByDate, Timestamp dateFilterMoment, boolean cache) { try { List<GenericValue> uomList = delegator.findByAnd("Uom", uomLookupFields, orderBy, cache); List<GenericValue> resultUomList = new ArrayList<>(uomList.size()); List<GenericValue> conversionList; for(GenericValue uom : uomList) { EntityCondition srcTargetCond; if (asTarget == Boolean.TRUE) { srcTargetCond = EntityCondition.makeCondition("uomIdTo", uom.getString("uomId")); } else if (asTarget == Boolean.FALSE) { srcTargetCond = EntityCondition.makeCondition("uomId", uom.getString("uomId")); } else { srcTargetCond = EntityCondition.makeCondition( EntityCondition.makeCondition("uomId", uom.getString("uomId")), EntityOperator.OR, EntityCondition.makeCondition("uomIdTo", uom.getString("uomId"))); } conversionList = delegator.findList("UomConversion", srcTargetCond, null, null, null, cache); if (!conversionList.isEmpty()) { resultUomList.add(uom); continue; } EntityCondition cond = srcTargetCond; if (filterByDate) { cond = EntityCondition.makeCondition(cond, EntityOperator.AND, dateFilterMoment != null ? EntityUtil.getFilterByDateExpr(dateFilterMoment) : EntityUtil.getFilterByDateExpr()); } conversionList = delegator.findList("UomConversionDated", cond, null, null, null, cache); if (!conversionList.isEmpty()) { resultUomList.add(uom); continue; } } return resultUomList; } catch(Exception e) { Debug.logError(e, module); return new ArrayList<>(); } }
Example #20
Source File: ParamAndColumnHintTest.java From birt with Eclipse Public License 1.0 | 4 votes |
public final void testFetchWithDateHint( ) throws DataException { String queryText = "select acDate, acTime, acTimestamp from acTimeDataTypes " + " where acDate < ? "; // If connection fails, fix connection properties m_statement = getLocalMySqlConnection( ).prepareStatement( queryText, JDBCOdaDataSource.DATA_SET_TYPE ); ParameterHint hint = new ParameterHint( "param1", true, false ); hint.setPosition( 1 ); // use param index below to match hints during retry hint.setDataType( Integer.class ); // use wrong one here to verify native type get used hint.setNativeDataType( Types.DATE ); m_statement.addParameterHint( hint ); // use a parameter value whose time portion is greater than the test data, // but expects the time portion gets truncated when applied to a Date parameter Timestamp ts = Timestamp.valueOf( "2000-10-13 03:13:00" ); m_statement.setParameterValue( 1, ts ); // since runtime metadata is available, column hint is not used ColumnHint columnHint = new ColumnHint( "acDate" ); columnHint.setDataType( Integer.class ); m_statement.addColumnHint( columnHint ); m_statement.execute( ); ResultSet resultSet = m_statement.getResultSet( ); IResultObject resultObject = null; int numRows = 0; while ( ( resultObject = resultSet.fetch( ) ) != null ) { numRows++; assertEquals( java.sql.Date.class, resultObject.getResultClass( ) .getFieldValueClass( "acDate" )); Object value = resultObject.getFieldValue( "acDate" ); assertTrue( value instanceof java.sql.Date ); } assertEquals( 0, numRows ); }
Example #21
Source File: LocalStorageHostRefVO.java From zstack with Apache License 2.0 | 4 votes |
public void setCreateDate(Timestamp createDate) { this.createDate = createDate; }
Example #22
Source File: PluginPackage.java From wecube-platform with Apache License 2.0 | 4 votes |
public void setUploadTimestamp(Timestamp uploadTimestamp) { this.uploadTimestamp = uploadTimestamp; }
Example #23
Source File: TransactionalAdhocFastList.java From reladomo with Apache License 2.0 | 4 votes |
public void cascadeInsertAllUntil(Timestamp exclusiveUntil) { MithraManagerProvider.getMithraManager().executeTransactionalCommand(new CascadeInsertAllUntilTransactionalCommand(this, exclusiveUntil)); }
Example #24
Source File: ShoppingCartItem.java From scipio-erp with Apache License 2.0 | 4 votes |
/** Returns the date to ship before */ public Timestamp getShipBeforeDate() { return this.shipBeforeDate; }
Example #25
Source File: JobNodeTriggerInfoRecord.java From spring-boot-starter-micro-job with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public Field<Timestamp> field6() { return JobNodeTriggerInfo.NTI_CREATE_TIME; }
Example #26
Source File: ShardEntity.java From Zebra with Apache License 2.0 | 4 votes |
public Timestamp getUpdateTime() { return updateTime; }
Example #27
Source File: DateTimeUtils.java From depotSample with Apache License 2.0 | 4 votes |
public static void main(String[] args) { long curr_time = System.currentTimeMillis(); java.sql.Date curr_date = format2SqlDateByDay("yyyyMMdd", curr_time,-1); Date curr_date_1 = format2DateByDay("yyyyMMdd", curr_time,-1); System.out.println("-1 : " + curr_date + " | " + curr_date_1); curr_date = format2SqlDateByDay("yyyyMMdd", curr_time,0); curr_date_1 = format2DateByDay("yyyyMMdd", curr_time,0); System.out.println("0 : " + curr_date+ " | " + curr_date_1); curr_date = format2SqlDateByDay("yyyyMMdd", curr_time,1); curr_date_1 = format2DateByDay("yyyyMMdd", curr_time,1); System.out.println("1 : " + curr_date+ " | " + curr_date_1); java.sql.Date t_date = format2SqlDate("yyyyMMdd", "20160906"); System.out.println("t_date : " + t_date); System.out.println("========================HOUR=============================="); Date curr_hour = format2DateByHour("yyyy-MM-dd hh:mm:ss",curr_time,-1); java.sql.Date curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd hh:mm:ss", curr_time,-1); System.out.println("hour -1 : " + formatDate("yyyy-MM-dd hh:mm:ss",curr_hour) + " | " + curr_hour_1); curr_hour = format2DateByHour("yyyy-MM-dd hh:mm:ss",curr_time,0); curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd hh:mm:ss", curr_time,0); System.out.println("hour 0 : " + formatDate("yyyy-MM-dd hh:mm:ss",curr_hour) + " | " + curr_hour_1); curr_hour = format2DateByHour("yyyy-MM-dd hh:mm:ss",curr_time,1); curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd hh:mm:ss", curr_time,1); System.out.println("hour 1: " + formatDate("yyyy-MM-dd hh:mm:ss",curr_hour) + " | " + curr_hour_1); System.out.println("========================MIN=============================="); Date curr_min = format2DateByMin("yyyy-MM-dd hh:mm:ss",curr_time,-1); java.sql.Date curr_min_1 = format2SqlDateByMin("yyyy-MM-dd hh:mm:ss", curr_time,-1); System.out.println("min -1 : " + formatDate("yyyy-MM-dd hh:mm:ss",curr_min) + " | " + curr_hour_1); curr_hour = format2DateByMin("yyyy-MM-dd hh:mm:ss",curr_time,0); curr_hour_1 = format2SqlDateByMin("yyyy-MM-dd hh:mm:ss", curr_time,0); System.out.println("min 0 : " + formatDate("yyyy-MM-dd hh:mm:ss",curr_min) + " | " + formatDate("yyyy-MM-dd hh:mm:ss",curr_hour_1)); curr_min = format2DateByMin("yyyy-MM-dd hh:mm:ss",curr_time,1); curr_min_1 = format2SqlDateByMin("yyyy-MM-dd hh:mm:ss", curr_time,1); System.out.println("min 1: " + formatDate("yyyy-MM-dd hh:mm:ss",curr_min) + " | " + curr_hour_1); System.out.println("=======================CHANGE START TIME==============================="); String start_time = "2016-10-14 00:00:30"; curr_time = format2Date("yyyy-MM-dd HH:mm:ss",start_time).getTime(); System.out.println("======================HOUR================================"); curr_hour = format2DateByHour("yyyy-MM-dd HH:mm:ss",curr_time,-1); curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd HH:mm:ss", curr_time,-1); System.out.println("hour -1 : " + formatDate("yyyy-MM-dd HH:mm:ss",curr_hour) + " | " + curr_hour_1); curr_hour = format2DateByHour("yyyy-MM-dd HH:mm:ss",curr_time,0); curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd HH:mm:ss", curr_time,0); System.out.println("hour 0 : " + formatDate("yyyy-MM-dd HH:mm:ss",curr_hour) + " | " + curr_hour_1); curr_hour = format2DateByHour("yyyy-MM-dd HH:mm:ss",curr_time,1); curr_hour_1 = format2SqlDateByHour("yyyy-MM-dd HH:mm:ss", curr_time,1); System.out.println("hour 1: " + formatDate("yyyy-MM-dd HH:mm:ss",curr_hour) + " | " + curr_hour_1); System.out.println("======================MIN================================"); curr_min = format2DateByMin("yyyy-MM-dd HH:mm:ss",curr_time,-1); curr_min_1 = format2SqlDateByMin("yyyy-MM-dd HH:mm:ss", curr_time,-1); System.out.println("min -1 : " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min) + " | " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min_1)); Date check_1 = curr_min; curr_min = format2DateByMin("yyyy-MM-dd HH:mm:ss",curr_time,0); curr_min_1 = format2SqlDateByMin("yyyy-MM-dd HH:mm:ss", curr_time,0); System.out.println("min 0 : " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min) + " | " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min_1)); curr_min = format2DateByMin("yyyy-MM-dd HH:mm:ss",curr_time,1); curr_min_1 = format2SqlDateByMin("yyyy-MM-dd HH:mm:ss", curr_time,1); System.out.println("min 1: " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min) + " | " + formatDate("yyyy-MM-dd HH:mm:ss",curr_min_1)); Date check_2 = curr_min; try { System.out.println(daysBetween(check_2,check_1)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("====================== before ========================"); curr_time = System.currentTimeMillis(); Date before_date = format2DateByMin("yyyy-MM-dd HH:mm:ss",curr_time,11); Date t_curr_date = format2DateByMin("yyyy-MM-dd HH:mm:ss",curr_time,15); System.out.println("before_date : " + before_date + " | t_curr_date : " + t_curr_date); Timestamp tp = format2Timestamp("yyyy-MM-dd HH:mm:ss","2016-10-18 13:12:27"); System.out.println(tp.before(t_curr_date)); }
Example #28
Source File: ElasticSearchResultSet.java From elasticsearch-sql with Apache License 2.0 | 4 votes |
@Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { return null; }
Example #29
Source File: TestDataLib.java From cerberus-source with GNU General Public License v3.0 | 4 votes |
public Timestamp getLastModified() { return lastModified; }
Example #30
Source File: DunningLetterServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * This method generates the actual pdf file with related invoices to the template to print. * * @param dunningLetterTemplate * @param dunningLetterDistributionLookupResult * @return */ protected byte[] createDunningLetters(DunningLetterTemplate dunningLetterTemplate, GenerateDunningLettersLookupResult dunningLetterDistributionLookupResult) { List<ContractsGrantsInvoiceDocument> selectedInvoices = new ArrayList<ContractsGrantsInvoiceDocument>(); byte[] reportStream = null; byte[] finalReportStream = null; int lastEventCode; if (ObjectUtils.isNotNull(dunningLetterTemplate) && dunningLetterTemplate.isActive() && ObjectUtils.isNotNull(dunningLetterTemplate.getFilename())) { // To get list of invoices per award per dunning letter template for (ContractsGrantsInvoiceDocument cgInvoice : dunningLetterDistributionLookupResult.getInvoices()) { if (StringUtils.equals(cgInvoice.getInvoiceGeneralDetail().getDunningLetterTemplateAssigned(), dunningLetterTemplate.getDunningLetterTemplateCode())) { selectedInvoices.add(cgInvoice); // 1. Now we know that the invoice is going to have its dunning letter processed. So we assume the letter is // sent and set the event for it. CollectionEvent event = new CollectionEvent(); event.setInvoiceNumber(cgInvoice.getDocumentNumber()); event.setCollectionEventCode(cgInvoice.getNextCollectionEventCode()); String activityCode = parameterService.getParameterValueAsString(CollectionActivityType.class, ArConstants.DUNNING_LETTER_GENERATION_CODE); if (StringUtils.isNotBlank(activityCode)) { event.setActivityCode(activityCode); event.setActivityDate(new java.sql.Date(new Date().getTime())); event.setActivityText(ArConstants.DunningLetters.DUNNING_LETTER_SENT_TXT); final Timestamp now = dateTimeService.getCurrentTimestamp(); event.setPostedDate(now); if (GlobalVariables.getUserSession() != null && GlobalVariables.getUserSession().getPerson() != null) { Person authorUniversal = GlobalVariables.getUserSession().getPerson(); event.setUserPrincipalId(authorUniversal.getPrincipalId()); event.setUser(authorUniversal); } businessObjectService.save(event); cgInvoice.getCollectionEvents().add(event); } // 2. To set the Last sent date of the dunning letter. cgInvoice.getInvoiceGeneralDetail().setDunningLetterTemplateSentDate(new java.sql.Date(new Date().getTime())); businessObjectService.save(cgInvoice); } } // to generate dunning letter from templates. ModuleConfiguration systemConfiguration = kualiModuleService.getModuleServiceByNamespaceCode(KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE).getModuleConfiguration(); String templateFolderPath = ((FinancialSystemModuleConfiguration) systemConfiguration).getTemplateFileDirectories().get(KFSConstants.TEMPLATES_DIRECTORY_KEY); String templateFilePath = templateFolderPath + File.separator + dunningLetterTemplate.getFilename(); File templateFile = new File(templateFilePath); File outputDirectory = null; String outputFileName; try { // Step2. add parameters to the dunning letter outputFileName = dunningLetterDistributionLookupResult.getProposalNumber() + getDateTimeService().toDateStringForFilename(getDateTimeService().getCurrentDate()) + ArConstants.TemplateUploadSystem.EXTENSION; Map<String, String> replacementList = getTemplateParameterList(selectedInvoices); CustomerAddress address; Map<String, Object> primaryKeys = new HashMap<String, Object>(); primaryKeys.put(KFSPropertyConstants.CUSTOMER_NUMBER, dunningLetterDistributionLookupResult.getCustomerNumber()); primaryKeys.put("customerAddressTypeCode", "P"); address = businessObjectService.findByPrimaryKey(CustomerAddress.class, primaryKeys); replacementList.put("agency.fullAddressInline", contractsGrantsBillingUtilityService.buildFullAddress(address)); replacementList.put("agency.fullName", address.getCustomer().getCustomerName()); replacementList.put("agency.contactName", address.getCustomer().getCustomerContactName()); if(CollectionUtils.isNotEmpty(selectedInvoices)){ reportStream = PdfFormFillerUtil.populateTemplate(templateFile, replacementList); // Step3. attach each dunning letter to invoice pdfs. finalReportStream = generateListOfInvoicesPdfToPrint(selectedInvoices, reportStream); } } catch (DocumentException | IOException ex) { // This means that the invoice pdfs were not generated properly. So get only the Dunning letters created. LOG.error("An exception occurred while retrieving invoice pdfs." + ex.getMessage()); finalReportStream = reportStream; } } else { GlobalVariables.getMessageMap().putError(KFSConstants.GLOBAL_ERRORS, ArKeyConstants.ERROR_FILE_UPLOAD_NO_PDF_FILE_SELECTED_FOR_SAVE, "test"); } return finalReportStream; }