java.sql.Date Java Examples
The following examples show how to use
java.sql.Date.
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 Project: kfs Author: kuali File: YearEndFlexibleOffsetTest.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Initialize defaults for each test. * @see org.kuali.kfs.gl.businessobject.OriginEntryTestBase#setUp() */ @Override public void setUp() throws Exception { super.setUp(); this.boService = SpringContext.getBean(BusinessObjectService.class); this.fiscalYear = new Integer((SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear()).intValue() - 1); this.transactionDate = new java.sql.Date(new java.util.Date().getTime()); this.parameterService = SpringContext.getBean(ParameterService.class); this.objectTypeService = SpringContext.getBean(ObjectTypeService.class); DEFAULT_FLEXIBLE_ENCUMBRANCE_SUB_ACCT_NBR = KFSConstants.getDashSubAccountNumber(); DEFAULT_NO_FLEXIBLE_ENCUMBRANCE_SUB_ACCT_NBR = KFSConstants.getDashSubAccountNumber(); createFlexibleOffsetAccounts(); }
Example #2
Source Project: gemfirexd-oss Author: gemxd File: TradeNetworthV1DMLDistTxStmt.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected void addUpdateToDerbyTx(long[] cid, long[] c_cid, BigDecimal[] availLoanDelta, BigDecimal[] sec, BigDecimal[] cashDelta, int[] newLoanLimit, Date[] since, BigDecimal[] cash, int[] whichUpdate, int[] updateCount, SQLException gfxdse){ Object[] data = new Object[13]; data[0] = DMLDistTxStmtsFactory.TRADE_NETWORTH; data[1] = "update"; data[2] = cid; data[3] = c_cid; data[4] = availLoanDelta; data[5] = sec; data[6] = cashDelta; data[7] = newLoanLimit; data[8] = since; data[9] = cash; data[10] = whichUpdate; data[11] = updateCount; data[12] = gfxdse; ArrayList<Object[]> derbyOps = (ArrayList<Object[]>)SQLDistTxTest.derbyOps.get(); if (derbyOps == null) derbyOps = new ArrayList<Object[]>(); derbyOps.add(data); SQLDistTxTest.derbyOps.set(derbyOps); }
Example #3
Source Project: phoenix Author: apache File: PDate.java License: Apache License 2.0 | 6 votes |
@Override public int compareTo(Object lhs, Object rhs, PDataType rhsType) { if (lhs == rhs) { return 0; } if (lhs == null) { return -1; } if (rhs == null) { return 1; } if (rhsType == PTimestamp.INSTANCE || rhsType == PUnsignedTimestamp.INSTANCE) { return -rhsType.compareTo(rhs, lhs, PTime.INSTANCE); } return ((java.util.Date) lhs).compareTo((java.util.Date) rhs); }
Example #4
Source Project: birt Author: eclipse File: ResultSet.java License: Eclipse Public License 1.0 | 6 votes |
/** * Transform a String value to a date value * * @param stringValue * String value * @return Corresponding date value * @throws OdaException */ private Date stringToDate(String stringValue) throws OdaException { if (stringValue != null && stringValue.trim().length() > 0) { try{ //return new Date (excelDateToDate(Double.parseDouble(stringValue)).getTime()); return DateUtil.toSqlDate( stringValue ); } catch( Exception ex){ throw new OdaException(Messages.getFormattedString( "invalid_date_value", new String[] { stringValue })); //$NON-NLS-1$ } } this.wasNull = true; return null; }
Example #5
Source Project: EasyTransaction Author: QNJR-GROUP File: OrderService.java License: Apache License 2.0 | 6 votes |
private Integer saveOrderRecord(JdbcTemplate jdbcTemplate, final int userId, final long money) { final String INSERT_SQL = "INSERT INTO `order` (`order_id`, `user_id`, `money`, `create_time`) VALUES (NULL, ?, ?, ?);"; KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update( new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(INSERT_SQL, new String[] {"id"}); ps.setInt(1, userId); ps.setLong(2, money); ps.setDate(3, new Date(System.currentTimeMillis())); return ps; } }, keyHolder); return keyHolder.getKey().intValue(); }
Example #6
Source Project: gemfirexd-oss Author: gemxd File: CustomersSecuritiesPortfolioSubqueryStmt.java License: Apache License 2.0 | 6 votes |
private ResultSet getUniqQuery3(Connection conn, int whichQuery, Date since, int tid) { boolean[] success = new boolean[1]; ResultSet rs = null; rs = getUniqQuery3(conn, whichQuery, since, tid, success); int count=0; while (!success[0]) { if (SQLHelper.isDerbyConn(conn) || count>=maxNumOfTries) { Log.getLogWriter().info("Could not get the resultSet " + "abort this operation"); return rs; } count++; rs = getUniqQuery3(conn, whichQuery, since, tid, success); } //retry return rs; }
Example #7
Source Project: kfs Author: kuali File: TaxableRamificationDocumentServiceImpl.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.module.tem.service.TaxableRamificationDocumentService#getAllQualifiedOutstandingTravelAdvance() */ @Override public List<TravelAdvance> getAllQualifiedOutstandingTravelAdvance() { List<TravelAdvance> qualifiedOutstandingTravelAdvance = new ArrayList<TravelAdvance>(); List<String> customerTypeCodes = this.getTravelerCustomerTypes(); Integer customerInvoiceAge = this.getNotificationOnDays(); Date lastTaxableRamificationNotificationDate = this.getLastTaxableRamificationNotificationDate(); if (ObjectUtils.isNull(lastTaxableRamificationNotificationDate)) { lastTaxableRamificationNotificationDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate(); } Map<String, KualiDecimal> invoiceOpenAmountMap = this.getAccountsReceivableModuleService().getCustomerInvoiceOpenAmount(customerTypeCodes, customerInvoiceAge, lastTaxableRamificationNotificationDate); Set<String> arInvoiceDocNumbers = invoiceOpenAmountMap.keySet(); if (ObjectUtils.isNotNull(arInvoiceDocNumbers) && !arInvoiceDocNumbers.isEmpty()) { qualifiedOutstandingTravelAdvance = this.getTravelDocumentService().getOutstandingTravelAdvanceByInvoice(arInvoiceDocNumbers); } return qualifiedOutstandingTravelAdvance; }
Example #8
Source Project: phoenix Author: cloudera-labs File: ProductMetricsIT.java License: Apache License 2.0 | 6 votes |
@Test public void testTruncateNotTraversableToFormScanKey() throws Exception { long ts = nextTimestamp(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM PRODUCT_METRICS WHERE organization_id = ? and TRUNC(date,'DAY') <= ?"; String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { Date startDate = toDate("2013-01-01 00:00:00"); initDateTableValues(tenantId, getSplits(tenantId), ts, startDate, 0.5); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); statement.setDate(2, new Date(startDate.getTime() + (long)(QueryConstants.MILLIS_IN_DAY * 0.25))); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); assertEquals("A", rs.getString(1)); assertTrue(rs.next()); assertEquals("B", rs.getString(1)); assertFalse(rs.next()); } finally { conn.close(); } }
Example #9
Source Project: kfs Author: kuali File: TaxableRamificationNotificationServiceImpl.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.module.tem.batch.service.TaxableRamificationNotificationService#sendTaxableRamificationReport(org.kuali.kfs.module.tem.businessobject.TravelAdvance, * java.sql.Date) */ @Override @Transactional public TaxableRamificationDocument createTaxableRamificationDocument(TravelAdvance travelAdvance, Date taxableRamificationNotificationDate) { if (ObjectUtils.isNull(travelAdvance)) { throw new RuntimeException("The given travel advance cannot be null."); } TaxableRamificationDocument taxRamificationDocument = this.getTaxableRamificationDocumentService().createAndBlanketApproveRamificationDocument(travelAdvance); if (ObjectUtils.isNotNull(taxRamificationDocument)) { travelAdvance.setTaxRamificationNotificationDate(taxableRamificationNotificationDate); this.getBusinessObjectService().save(travelAdvance); } return taxRamificationDocument; }
Example #10
Source Project: logistics-back Author: anselleeyy File: CustomerBillClear.java License: MIT License | 6 votes |
public CustomerBillClear(String customerCode, String goodsBillCode, double billMoney, double moneyReceivable, double receivedMoney, double prepayMoney, double carriageReduceFund, double balance, Date balanceTime, double insurance, double payKickback, double carryGoodsFee, String balanceType) { super(); CustomerCode = customerCode; this.goodsBillCode = goodsBillCode; this.billMoney = billMoney; this.moneyReceivable = moneyReceivable; this.receivedMoney = receivedMoney; this.prepayMoney = prepayMoney; this.carriageReduceFund = carriageReduceFund; this.balance = balance; this.balanceTime = balanceTime; this.insurance = insurance; this.payKickback = payKickback; this.carryGoodsFee = carryGoodsFee; this.balanceType = balanceType; }
Example #11
Source Project: FastDFS_Client Author: tobato File: FieldMetaData.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * 将属性值转换为byte * * @param charset * @return * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalAccessException */ public byte[] toByte(Object bean, Charset charset) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { Object value = this.getFieldValue(bean); if (isDynamicField()) { return getDynamicFieldByteValue(value, charset); } else if (String.class.equals(field.getType())) { // 如果是动态属性 return BytesUtil.objString2Byte((String) value, max, charset); } else if (long.class.equals(field.getType())) { return BytesUtil.long2buff((long) value); } else if (int.class.equals(field.getType())) { return BytesUtil.long2buff((int) value); } else if (Date.class.equals(field.getType())) { throw new FdfsColumnMapException("Date 还不支持"); } else if (byte.class.equals(field.getType())) { byte[] result = new byte[1]; result[0] = (byte) value; return result; } else if (boolean.class.equals(field.getType())) { throw new FdfsColumnMapException("boolean 还不支持"); } throw new FdfsColumnMapException("将属性值转换为byte时未识别的FdfsColumn类型" + field.getName()); }
Example #12
Source Project: presto Author: prestosql File: ObjectCasts.java License: Apache License 2.0 | 6 votes |
public static Date castToDate(Object x, int targetSqlType) throws SQLException { if (x instanceof Date) { return (Date) x; } if (x instanceof java.util.Date) { return new Date(((java.util.Date) x).getTime()); } if (x instanceof LocalDate) { return Date.valueOf((LocalDate) x); } if (x instanceof LocalDateTime) { return Date.valueOf(((LocalDateTime) x).toLocalDate()); } try { if (x instanceof String) { return Date.valueOf((String) x); } } catch (RuntimeException e) { throw invalidConversion(x, targetSqlType, e); } throw invalidConversion(x, targetSqlType); }
Example #13
Source Project: phoenix Author: forcedotcom File: WhereClauseOptimizerTest.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testLessThanRound() throws Exception { String inst = "a"; String host = "b"; Date startDate = DateUtil.parseDate("2012-01-01 01:00:00"); Date endDate = DateUtil.parseDate("2012-01-02 00:00:00"); String query = "select * from ptsdb where inst=? and host=? and round(date,'DAY')<?"; Scan scan = new Scan(); List<Object> binds = Arrays.<Object>asList(inst,host,startDate); compileStatement(query, scan, binds); byte[] startRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(inst),QueryConstants.SEPARATOR_BYTE_ARRAY, PDataType.VARCHAR.toBytes(host),QueryConstants.SEPARATOR_BYTE_ARRAY); assertArrayEquals(startRow, scan.getStartRow()); byte[] stopRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(inst),QueryConstants.SEPARATOR_BYTE_ARRAY, PDataType.VARCHAR.toBytes(host),QueryConstants.SEPARATOR_BYTE_ARRAY, PDataType.DATE.toBytes(endDate)); assertArrayEquals(stopRow, scan.getStopRow()); }
Example #14
Source Project: gemfirexd-oss Author: gemxd File: CustomersSecuritiesPortfolioSubqueryStmt.java License: Apache License 2.0 | 6 votes |
private ResultSet getUniqQuery0(Connection conn, int whichQuery, Date since, int tid) { boolean[] success = new boolean[1]; ResultSet rs = null; rs = getUniqQuery0(conn, whichQuery, since, tid, success); int count=0; while (!success[0]) { if (SQLHelper.isDerbyConn(conn) || count>=maxNumOfTries) { Log.getLogWriter().info("Could not get the resultSet " + "abort this operation"); return rs; } count++; rs = getUniqQuery0(conn, whichQuery, since, tid, success); } //retry return rs; }
Example #15
Source Project: phoenix Author: cloudera-labs File: WhereOptimizerTest.java License: Apache License 2.0 | 6 votes |
@Test public void testGreaterThanRound() throws Exception { String inst = "a"; String host = "b"; Date startDate = DateUtil.parseDate("2012-01-01 01:00:00"); Date endDate = DateUtil.parseDate("2012-01-02 00:00:00"); String query = "select * from ptsdb where inst=? and host=? and round(date,'DAY')>?"; List<Object> binds = Arrays.<Object>asList(inst,host,startDate); Scan scan = compileStatement(query, binds).getScan(); assertNull(scan.getFilter()); byte[] startRow = ByteUtil.concat(PVarchar.INSTANCE.toBytes(inst),QueryConstants.SEPARATOR_BYTE_ARRAY, PVarchar.INSTANCE.toBytes(host),QueryConstants.SEPARATOR_BYTE_ARRAY, PDate.INSTANCE.toBytes(endDate)); assertArrayEquals(startRow, scan.getStartRow()); byte[] stopRow = ByteUtil.nextKey(ByteUtil.concat(PVarchar.INSTANCE.toBytes(inst),QueryConstants.SEPARATOR_BYTE_ARRAY, PVarchar.INSTANCE.toBytes(host),QueryConstants.SEPARATOR_BYTE_ARRAY)); assertArrayEquals(stopRow, scan.getStopRow()); }
Example #16
Source Project: gemfirexd-oss Author: gemxd File: TradeCustomersDMLStmt.java License: Apache License 2.0 | 5 votes |
protected void getDataForUpdate(String[] cust_name, Date[] since, String[] addr, int size) { int data = 1000; String temp; if (!randomData) { //update since using the same date if not random for (int i=0; i<size; i++) { temp = cust_name[i]; //Log.getLogWriter().info("temp is " + temp); if (temp.indexOf('_') != -1) { cust_name[i] = temp.substring(0, temp.indexOf('_')+1) +(Integer.parseInt(temp.substring(temp.indexOf('_')+1))+1); } else { cust_name[i] += "_1"; }//update of name temp = addr[i]; if (temp.indexOf('_') != -1) { addr[i] = temp.substring(0, temp.indexOf('_')+1) + (Integer.parseInt(temp.substring(temp.indexOf('_')+1))+1); } else { addr[i] += "_1"; } } //update of address } else { for (int i=0; i<size; i++) { cust_name[i] = "name" + rand.nextInt(data); addr[i] = "address is " + cust_name[i]; since[i] = getSince(); }//random data for update } }
Example #17
Source Project: effectivejava Author: ftomassetti File: ResultSetWrappingSqlRowSet.java License: Apache License 2.0 | 5 votes |
/** * @see java.sql.ResultSet#getDate(int, java.util.Calendar) */ @Override public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { try { return this.resultSet.getDate(columnIndex, cal); } catch (SQLException se) { throw new InvalidResultSetAccessException(se); } }
Example #18
Source Project: gemfirexd-oss Author: gemxd File: SQLDate.java License: Apache License 2.0 | 5 votes |
/** * Get the value field. We instantiate the field * on demand. * * @return The value field. */ public Date getDate( Calendar cal) { if (isNull()) return null; return new Date(getTimeInMillis(cal)); }
Example #19
Source Project: kfs Author: kuali File: TravelAuthorizationServiceImpl.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public List<String> findMatchingTrips(TravelAuthorizationDocument authorization) { List<String> duplicateTrips = new ArrayList<String>(); Date tripBeginBufferDate = authorization.getTripBegin() == null ? null : getTripBeginDate(authorization.getTripBegin()); Date tripEndBufferDate = authorization.getTripEnd() == null ? null : getTripEndDate(authorization.getTripEnd()); if (tripBeginBufferDate == null || tripEndBufferDate == null) { return duplicateTrips; // return the empty list. don't worry though - without a trip begin or end, they're certainly coming back } List<TravelAuthorizationDocument> authorizationDocuments = travelAuthorizationDao.findTravelAuthorizationByTraveler(authorization.getTemProfileId()); for (TravelAuthorizationDocument authorizationDocument : authorizationDocuments) { List<TravelReimbursementDocument> travelReimbursementDocuments = travelDocumentService.findReimbursementDocuments(authorizationDocument.getTravelDocumentIdentifier()); if(!ObjectUtils.isNull(travelReimbursementDocuments) && !travelReimbursementDocuments.isEmpty()) { boolean matchFound = matchReimbursements(travelReimbursementDocuments, tripBeginBufferDate, tripEndBufferDate); if(matchFound) { duplicateTrips.add(authorizationDocument.getDocumentNumber()); } } else { // look for TA's Date tripBeginDate = convertToSqlDate(authorizationDocument.getTripBegin()); Date tripEndDate = convertToSqlDate(authorizationDocument.getTripEnd()); if(!authorization.getDocumentNumber().equals(authorizationDocument.getDocumentNumber()) && doesDatesOverlap(tripBeginBufferDate, tripEndBufferDate, tripBeginDate,tripEndDate)){ duplicateTrips.add(authorizationDocument.getDocumentNumber()); } } } return duplicateTrips; }
Example #20
Source Project: phoenix Author: forcedotcom File: RoundFloorCeilFunctionsEnd2EndTest.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testRoundingUpDate() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(dt, 'day'), ROUND(dt, 'hour', 1), ROUND(dt, 'minute', 1), ROUND(dt, 'second', 1), ROUND(dt, 'millisecond', 1) FROM ROUND_DATE_TIME_TS_DECIMAL"); assertTrue(rs.next()); Date expectedDate = DateUtil.parseDate("2012-01-02 00:00:00"); assertEquals(expectedDate, rs.getDate(1)); expectedDate = DateUtil.parseDate("2012-01-01 14:00:00"); assertEquals(expectedDate, rs.getDate(2)); expectedDate = DateUtil.parseDate("2012-01-01 14:25:00"); assertEquals(expectedDate, rs.getDate(3)); expectedDate = DateUtil.parseDate("2012-01-01 14:25:29"); assertEquals(expectedDate, rs.getDate(4)); }
Example #21
Source Project: javalite Author: javalite File: ConvertTest.java License: Apache License 2.0 | 5 votes |
@Test public void shouldCovertToSqlDate() throws ParseException { Date d = new Date(new SimpleDateFormat("yyyy-MM-dd").parse("2001-01-01").getTime()); Date d1 = Convert.toSqlDate("2001-01-01"); a(d).shouldBeEqual(d1); Date date = Convert.toSqlDate(1416127392928L); a(date.toString()).shouldBeEqual("2014-11-16"); }
Example #22
Source Project: kfs Author: kuali File: CustomerInvoiceDocumentDaoOjb.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<CustomerInvoiceDocument> getAllAgingInvoiceDocumentsByCustomerTypes(List<String> customerTypes, Date invoiceDueDateFrom, Date invoiceDueDateTo) { LOG.info("invoiceDueDateFrom :::::" + invoiceDueDateFrom); LOG.info("invoiceDueDateTo ::::::::" + invoiceDueDateTo); Criteria criteria = this.getAllAgingInvoiceDocumentsCriteria(StringUtils.EMPTY, invoiceDueDateFrom, invoiceDueDateTo); if(ObjectUtils.isNotNull(customerTypes)){ criteria.addIn(ArPropertyConstants.CustomerInvoiceDocumentFields.CUSTOMER_TYPE_CODE, customerTypes); } Query query = QueryFactory.newQuery(CustomerInvoiceDocument.class, criteria); return getPersistenceBrokerTemplate().getCollectionByQuery(query); }
Example #23
Source Project: tcc-transaction Author: Duttor File: TransactionRecoveryServiceImpl.java License: Apache License 2.0 | 5 votes |
@Override public List<TransactionInfo> fetchData(List<Integer> shardingItem) { // 30天前 Date searchDate = DateUtil.getPrevDate(day); // parentId 升序,txId升序 return transactionRepository.findSince(searchDate, shardingItem.toArray(new Integer[shardingItem.size()]), springContextUtil.getModuleId()); }
Example #24
Source Project: phoenix Author: apache File: ParameterizedTransactionIT.java License: Apache License 2.0 | 5 votes |
@Test public void testCurrentDate() throws Exception { String transTableName = generateUniqueName(); String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName; String selectSql = "SELECT current_date() FROM "+fullTableName; try (Connection conn = DriverManager.getConnection(getUrl())) { conn.createStatement().execute("create table " + fullTableName + TestUtil.TEST_TABLE_SCHEMA + tableDDLOptions + (tableDDLOptions.length() > 0 ? "," : "") + "TRANSACTIONAL=true"); conn.setAutoCommit(false); ResultSet rs = conn.createStatement().executeQuery(selectSql); assertFalse(rs.next()); String upsert = "UPSERT INTO " + fullTableName + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); // upsert two rows TestUtil.setRowKeyColumns(stmt, 1); stmt.execute(); conn.commit(); rs = conn.createStatement().executeQuery(selectSql); assertTrue(rs.next()); Date date1 = rs.getDate(1); assertFalse(rs.next()); Thread.sleep(1000); rs = conn.createStatement().executeQuery(selectSql); assertTrue(rs.next()); Date date2 = rs.getDate(1); assertFalse(rs.next()); assertTrue("current_date() should change while executing multiple statements", date2.getTime() > date1.getTime()); } }
Example #25
Source Project: spliceengine Author: splicemachine File: SpliceDateFunctions.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * Implements the LAST_DAY function */ public static Date LAST_DAY(Date source) { if (source == null) { return null; } DateTime dt = new DateTime(source).dayOfMonth().withMaximumValue(); return new Date(dt.getMillis()); }
Example #26
Source Project: clickhouse-jdbc Author: ClickHouse File: BatchInsertsTest.java License: Apache License 2.0 | 5 votes |
@Test public void testBatchValuesColumn() throws SQLException { connection.createStatement().execute("DROP TABLE IF EXISTS test.batch_single_test"); connection.createStatement().execute( "CREATE TABLE test.batch_single_test(date Date, values String) ENGINE = StripeLog" ); PreparedStatement st = connection.prepareStatement("INSERT INTO test.batch_single_test (date, values) VALUES (?, ?)"); st.setDate(1, new Date(System.currentTimeMillis())); st.setString(2, "test"); st.addBatch(); st.executeBatch(); }
Example #27
Source Project: jaybird Author: FirebirdSQL File: DefaultDatatypeCoder.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public Date encodeDate(java.sql.Date d, Calendar cal) { if (cal == null) { return (d); } else { cal.setTime(d); return new Date(cal.getTime().getTime()); } }
Example #28
Source Project: PlotMe-Core Author: WorldCretornica File: Plot.java License: GNU General Public License v3.0 | 5 votes |
public Plot(long internalID, String owner, UUID ownerId, IWorld world, String biome, Date expiredDate, HashMap<String, AccessLevel> allowed, HashSet<String> denied, HashSet<UUID> likers, PlotId id, double price, boolean forSale, boolean finished, String finishedDate, boolean protect, Map<String, Map<String, String>> metadata, int plotLikes, String plotName, Vector topLoc, Vector bottomLoc, String createdDate) { this.internalID = internalID; this.owner = owner; this.ownerId = ownerId; this.world = world; this.biome = biome; this.expiredDate = expiredDate; this.finished = finished; this.finishedDate = finishedDate; this.allowed.putAll(allowed); this.id = id; this.price = price; this.forSale = forSale; this.finishedDate = finishedDate; this.protect = protect; this.likers.addAll(likers); this.plotName = plotName; this.likes = plotLikes; this.denied.addAll(denied); this.metadata.putAll(metadata); this.plotTopLoc = topLoc; this.plotBottomLoc = bottomLoc; this.createdDate = createdDate; }
Example #29
Source Project: phoenix Author: cloudera-labs File: ProductMetricsIT.java License: Apache License 2.0 | 5 votes |
@Test public void testRoundAggregation() throws Exception { long ts = nextTimestamp(); String tenantId = getOrganizationId(); String query = "SELECT round(date,'hour',1) r,count(1) FROM PRODUCT_METRICS WHERE organization_id=? GROUP BY r"; String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5 Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { initTableValues(tenantId, getSplits(tenantId), ts); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, tenantId); Date d; int c; ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); d = rs.getDate(1); c = rs.getInt(2); assertEquals(1 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 1 hr assertEquals(2, c); assertTrue(rs.next()); d = rs.getDate(1); c = rs.getInt(2); assertEquals(2 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 2 hr assertEquals(3, c); assertTrue(rs.next()); d = rs.getDate(1); c = rs.getInt(2); assertEquals(4 * 60 * 60 * 1000, d.getTime()); // Date bucketed into 4 hr assertEquals(1, c); assertFalse(rs.next()); } finally { conn.close(); } }
Example #30
Source Project: flink Author: flink-tpc-ds File: SqlDateSerializer.java License: Apache License 2.0 | 5 votes |
@Override public Date copy(Date from) { if (from == null) { return null; } return new Date(from.getTime()); }