类java.sql.Date源码实例Demo

下面列出了怎么用java.sql.Date的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: kfs   文件: YearEndFlexibleOffsetTest.java
/**
 * 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();
}
 
@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);
}
 
源代码3 项目: phoenix   文件: PDate.java
@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);
}
 
源代码4 项目: birt   文件: ResultSet.java
/**
 * 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;
}
 
源代码5 项目: EasyTransaction   文件: OrderService.java
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();
}
 
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;
}
 
/**
 * @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;
}
 
源代码8 项目: phoenix   文件: ProductMetricsIT.java
@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();
    }
}
 
/**
 * @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;
}
 
源代码10 项目: logistics-back   文件: CustomerBillClear.java
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;
}
 
源代码11 项目: FastDFS_Client   文件: FieldMetaData.java
/**
 * 将属性值转换为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());
}
 
源代码12 项目: presto   文件: ObjectCasts.java
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);
}
 
源代码13 项目: phoenix   文件: WhereClauseOptimizerTest.java
@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());
}
 
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;
}
 
源代码15 项目: phoenix   文件: WhereOptimizerTest.java
@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());
}
 
源代码16 项目: gemfirexd-oss   文件: TradeCustomersDMLStmt.java
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
  }    
}
 
源代码17 项目: effectivejava   文件: ResultSetWrappingSqlRowSet.java
/**
 * @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);
	}
}
 
源代码18 项目: gemfirexd-oss   文件: SQLDate.java
/**
 * 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));
}
 
源代码19 项目: kfs   文件: TravelAuthorizationServiceImpl.java
@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;

}
 
@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));
}
 
源代码21 项目: javalite   文件: ConvertTest.java
@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");
}
 
源代码22 项目: kfs   文件: CustomerInvoiceDocumentDaoOjb.java
@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);
}
 
@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());
}
 
源代码24 项目: phoenix   文件: ParameterizedTransactionIT.java
@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());
    }
}
 
源代码25 项目: spliceengine   文件: SpliceDateFunctions.java
/**
 * 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());
}
 
源代码26 项目: clickhouse-jdbc   文件: BatchInsertsTest.java
@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();
}
 
源代码27 项目: jaybird   文件: DefaultDatatypeCoder.java
@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());
    }
}
 
源代码28 项目: PlotMe-Core   文件: Plot.java
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;
}
 
源代码29 项目: phoenix   文件: ProductMetricsIT.java
@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();
    }
}
 
源代码30 项目: flink   文件: SqlDateSerializer.java
@Override
public Date copy(Date from) {
	if (from == null) {
		return null;
	}
	return new Date(from.getTime());
}