当前位置: 首页>>代码示例>>Java>>正文


Java Timestamp类代码示例

本文整理汇总了Java中java.sql.Timestamp的典型用法代码示例。如果您正苦于以下问题:Java Timestamp类的具体用法?Java Timestamp怎么用?Java Timestamp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Timestamp类属于java.sql包,在下文中一共展示了Timestamp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recordToDto

import java.sql.Timestamp; //导入依赖的package包/类
private static TransferTimingListingDTO recordToDto(Record16<Long, Integer, Integer, String, String, String, String, Integer, Integer, String, String, String, Byte, Timestamp, Timestamp, Long> r) {
    // You can do your mapping manually or use jooq methods like "into" etc
    return new TransferTimingListingDTO(
        r.get(TRANSFER_TIMING_FILE_TRANSITION_HISTORY_ID, Long.class),
        r.get("fileId", Long.class),
        r.get("atableId", Long.class),
        r.get("atableName", String.class),
        r.get(USER.USERNAME, String.class),
        r.get(FILE.CODE, String.class),
        r.get("fileTypeName", String.class),
        r.get(TRANSFER_TIMING_VISUAL_COUNT, Integer.class),
        r.get(TRANSFER_TIMING_SOMETHING_COUNT, Integer.class),
        r.get(field("fromStatus"), String.class),
        r.get(field("toStatus"), String.class),
        r.get(FILE_TRANSITION_HISTORY.LOCATION_IPV4, String.class),
        r.get(TRANSFER_TIMING_TRANSFER_STATUS, Boolean.class),
        // Set zone to specific one if you are not using UTC (you should)
        r.get(TRANSFER_TIMING_TRANSFER_STARTED_AT).toLocalDateTime().atZone(DATABASE_TIMEZONE),
        r.get(TRANSFER_TIMING_TRANSFER_ENDED_AT).toLocalDateTime().atZone(DATABASE_TIMEZONE),
        r.get(TRANSFER_TIMING_TRANSFER_TIME_SPENT_IN_SECONDS, Long.class)
    );
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:23,代码来源:TransferTimingPageRepositoryImplPureJooq.java

示例2: testExecuteBatchFilter

import java.sql.Timestamp; //导入依赖的package包/类
@Test
public void testExecuteBatchFilter() throws Exception {
	truncateTable("product");
	Timestamp currentDatetime = Timestamp.valueOf("2005-12-12 10:10:10.000000000");
	List<String> log = TestAppender.getLogbackLogs(() -> {
		SqlContext ctx = agent.contextFrom("example/insert_product").setSqlId("333")
				.param("product_id", new BigDecimal(1)).param("product_name", "商品名1")
				.param("product_kana_name", "ショウヒンメイイチ").param("jan_code", "1234567890123")
				.param("product_description", "1番目の商品").param("ins_datetime", currentDatetime)
				.param("upd_datetime", currentDatetime).param("version_no", new BigDecimal(0)).addBatch()
				.param("product_id", new BigDecimal(2)).param("product_name", "商品名2")
				.param("product_kana_name", "ショウヒンメイニ").param("jan_code", "1234567890124")
				.param("product_description", "2番目の商品").param("ins_datetime", currentDatetime)
				.param("upd_datetime", currentDatetime).param("version_no", new BigDecimal(0))
				.param("_userName", "testUserName").param("_funcId", "testFunction").addBatch();
		agent.batch(ctx);
	});

	assertThat(log,
			is(Files.readAllLines(
					Paths.get("src/test/resources/data/expected/DebugSqlFilter", "testExecuteBatchFilter.txt"),
					StandardCharsets.UTF_8)));
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:24,代码来源:DebugSqlFilterTest.java

示例3: delete

import java.sql.Timestamp; //导入依赖的package包/类
/**
 * 删除资产名称
 * @return
 */
public String delete()
{
    Log.infoFileSync("====================开始调用删除资产名称信息方法delete()================");
    try 
    {
        assetnameService.delete(model.getAssetNameID());
        tipMsg = "成功";
        tipType = 0;
    } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetNameID() + "  的资产名称异常", e);
        tipMsg = "失败";
        tipType = 1;
    }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除资产名称", model.getClientIp(),
            new Timestamp(System.currentTimeMillis())
    , tipType, "删除资产名称ID为  "+ model.getAssetNameID() + " " + tipMsg + "!", "删除资产名称" + tipMsg));
    Log.infoFileSync("====================结束调用删除资产名称信息方法delete()================");
    return SUCCESS;
}
 
开发者ID:cendi2005,项目名称:jshERP,代码行数:27,代码来源:AssetNameAction.java

示例4: extractors

import java.sql.Timestamp; //导入依赖的package包/类
/**
 * Initializes the default set of extractors
 * @return      the defailt set of extractors
 */
private static Map<Class<?>,SQLExtractor> extractors() {
    if (!initialized) {
        extractorMap.put(boolean.class, new BooleanExtractor());
        extractorMap.put(int.class, new IntegerExtractor());
        extractorMap.put(long.class, new LongExtractor());
        extractorMap.put(double.class, new DoubleExtractor());
        extractorMap.put(Boolean.class, new BooleanExtractor());
        extractorMap.put(Integer.class, new IntegerExtractor());
        extractorMap.put(Long.class, new LongExtractor());
        extractorMap.put(Double.class, new DoubleExtractor());
        extractorMap.put(String.class, new StringExtractor());
        extractorMap.put(java.util.Date.class, new DateExtractor());
        extractorMap.put(java.sql.Date.class, new DateExtractor());
        extractorMap.put(java.sql.Time.class, new TimeExtractor());
        extractorMap.put(Timestamp.class, new TimestampExtractor());
        extractorMap.put(LocalDate.class, new LocalDateExtractor());
        extractorMap.put(LocalTime.class, new LocalTimeExtractor());
        extractorMap.put(LocalDateTime.class, new LocalDateTimeExtractor());
        initialized = true;
    }
    return extractorMap;
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:27,代码来源:SQLExtractor.java

示例5: delete

import java.sql.Timestamp; //导入依赖的package包/类
/**
 * 删除单据
 * @return
 */
public String delete() {
    Log.infoFileSync("====================开始调用删除单据信息方法delete()================");
    try {
    	depotHeadService.delete(model.getDepotHeadID());
           tipMsg = "成功";
           tipType = 0;
       } 
    catch (DataAccessException e) {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotHeadID() + "  的单据异常", e);
        tipMsg = "失败";
           tipType = 1;
       }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除单据", model.getClientIp(),
            new Timestamp(System.currentTimeMillis())
    , tipType, "删除单据ID为  "+ model.getDepotHeadID() + " " + tipMsg + "!", "删除单据" + tipMsg));
    Log.infoFileSync("====================结束调用删除单据信息方法delete()================");
    return SUCCESS;
}
 
开发者ID:cendi2005,项目名称:jshERP,代码行数:24,代码来源:DepotHeadAction.java

示例6: onCommand

import java.sql.Timestamp; //导入依赖的package包/类
@Override
public void onCommand(User sender, MessageChannel channel, Message message, String[] args, Member member) {
    // Get the time since the message sent by the user was created.
    long pongTime = message.getCreationTime().until(ZonedDateTime.now(), ChronoUnit.MILLIS);
    channel.sendMessage("Pong! `" + pongTime + "ms`").queue();
    try {
        SQLController.runSqlTask(conn -> {
            PreparedStatement statement = conn.prepareStatement("INSERT INTO pings (time_pinged, response_time) VALUES (?, ?)");
            statement.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now()));
            statement.setLong(2, pongTime);
            statement.execute();
        });
    } catch (SQLException e) {
        ExampleBot.LOGGER.error("There was an error inserting into the MySQL table.", e);
    }
}
 
开发者ID:WalshyDev,项目名称:JBA,代码行数:17,代码来源:PingCommand.java

示例7: testAppendWithTimestamp

import java.sql.Timestamp; //导入依赖的package包/类
public void testAppendWithTimestamp() throws Exception {
  // Create a table with data in it; import it.
  // Then add more data, verify that only the incremental data is pulled.

  final String TABLE_NAME = "appendTimestamp";
  Timestamp thePast = new Timestamp(System.currentTimeMillis() - 100);
  createTimestampTable(TABLE_NAME, 10, thePast);

  List<String> args = getArgListForTable(TABLE_NAME, false, false);
  args.add("--append");
  createJob(TABLE_NAME, args);
  runJob(TABLE_NAME);
  assertDirOfNumbers(TABLE_NAME, 10);

  // Add some more rows.
  long importWasBefore = System.currentTimeMillis();
  Thread.sleep(50);
  long rowsAddedTime = System.currentTimeMillis() - 5;
  assertTrue(rowsAddedTime > importWasBefore);
  assertTrue(rowsAddedTime < System.currentTimeMillis());
  insertIdTimestampRows(TABLE_NAME, 10, 20, new Timestamp(rowsAddedTime));

  // Import only those rows.
  runJob(TABLE_NAME);
  assertDirOfNumbers(TABLE_NAME, 20);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:27,代码来源:TestIncrementalImport.java

示例8: testBug54095

import java.sql.Timestamp; //导入依赖的package包/类
/**
 * Tests fix for BUG#54095 - Unnecessary call in newSetTimestampInternal.
 *
 * This bug was fixed as a consequence of the patch for Bug#71084.
 *
 * @throws Exception
 *             if the test fails.
 */
public void testBug54095() throws Exception {
    Connection testConn = getConnectionWithProps("useLegacyDatetimeCode=false");

    Calendar testCal = Calendar.getInstance();
    java.util.Date origDate = testCal.getTime();

    PreparedStatement testPstmt = testConn.prepareStatement("SELECT ?");
    testPstmt.setTimestamp(1, new Timestamp(0), testCal);
    assertEquals("Calendar object shouldn't have changed after PreparedStatement.setTimestamp().", origDate, testCal.getTime());

    ResultSet testRs = testPstmt.executeQuery();
    testRs.next();
    assertEquals("Calendar object shouldn't have changed after PreparedStatement.executeQuery().", origDate, testCal.getTime());

    testRs.getTimestamp(1, testCal);
    assertEquals("Calendar object shouldn't have changed after ResultSet.getTimestamp().", origDate, testCal.getTime());

    testRs.close();
    testPstmt.close();
    testConn.close();
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:30,代码来源:StatementRegressionTest.java

示例9: buildSurvey

import java.sql.Timestamp; //导入依赖的package包/类
private static SurveyEntity buildSurvey(UserEntity owner, List<QuestionEntity> questionEntities) {
    SurveyEntity survey = new SurveyEntity();
    survey.setName("Testundersøkelse");
    survey.setCode("testabc");
    survey.setId(1);
    survey.setDateCreated(new Timestamp(System.currentTimeMillis()));
    survey.setDeadline(new Timestamp(System.currentTimeMillis() + 36000));
    survey.setQuestions(questionEntities);
    survey.setOwner(owner);

    for (QuestionEntity q : questionEntities) {
        q.setSurvey(survey);
    }

    return survey;
}
 
开发者ID:erikns,项目名称:webpoll,代码行数:17,代码来源:SurveyAnsweringModelBuilder.java

示例10: insertLogin

import java.sql.Timestamp; //导入依赖的package包/类
@Override
public Userlogin insertLogin(Userinfo userinfo) throws Exception{
	String user_email = userinfo.getUser_email();
	String user_password = userinfo.getUser_password();
	Map userinfoMap = new HashMap<>();
	userinfoMap.put("user_email", user_email);
	userinfoMap.put("user_password", user_password);
	List<Userinfo> loginUserInfo = userinfoDaoImpl.loginUserInfo(userinfoMap);
	//设置登陆的id
	long token_id = snowflakeIdUtil.nextId();
	//放到数据库中  
	Userlogin userlogin = new Userlogin();
	userlogin.setToken_id("#"+String.valueOf(token_id));
	userlogin.setUser_id(loginUserInfo.get(0).getUser_id());
	userlogin.setUser_login_time(String.valueOf( new Timestamp( (new Date()).getTime()) ));
	userloginDaoImpl.insertUserlogin(userlogin);
	userlogin.setToken_id(String.valueOf(token_id));
	return userlogin;
}
 
开发者ID:viakiba,项目名称:karanotes,代码行数:20,代码来源:UserinfoServiceImpl.java

示例11: delete

import java.sql.Timestamp; //导入依赖的package包/类
/**
 * 删除收支项目
 * @return
 */
public String delete()
{
    Log.infoFileSync("====================开始调用删除收支项目信息方法delete()================");
    try 
    {
        inOutItemService.delete(model.getInOutItemID());
        tipMsg = "成功";
        tipType = 0;
    } 
    catch (DataAccessException e) 
    {
        Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getInOutItemID() + "  的收支项目异常", e);
        tipMsg = "失败";
        tipType = 1;
    }
    model.getShowModel().setMsgTip(tipMsg);
    logService.create(new Logdetails(getUser(), "删除收支项目", model.getClientIp(),
     new Timestamp(System.currentTimeMillis())
    , tipType, "删除收支项目ID为  "+ model.getInOutItemID() + ",名称为  " + model.getName() + tipMsg + "!", "删除收支项目" + tipMsg));
    Log.infoFileSync("====================结束调用删除收支项目信息方法delete()================");
    return SUCCESS;
}
 
开发者ID:cendi2005,项目名称:jshERP,代码行数:27,代码来源:InOutItemAction.java

示例12: calculateExpiryDate

import java.sql.Timestamp; //导入依赖的package包/类
public EmailVerification calculateExpiryDate() {
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Timestamp(cal.getTime().getTime()));
    cal.add(Calendar.MINUTE, EXPIRATION);
    this.expiryDate = new Date(cal.getTime().getTime());
    return this;
}
 
开发者ID:quebic-source,项目名称:microservices-sample-project,代码行数:8,代码来源:EmailVerification.java

示例13: getCreated

import java.sql.Timestamp; //导入依赖的package包/类
public final Timestamp getCreated() {
	Connection con = DatabaseConnection.getConnection();
	try {
		PreparedStatement ps;
		ps = con.prepareStatement("SELECT createdat FROM accounts WHERE id = ?");
		ps.setInt(1, getAccID());
		Timestamp ret;
		try (ResultSet rs = ps.executeQuery()) {
			if (!rs.next()) {
				rs.close();
				ps.close();
				return null;
			}
			ret = rs.getTimestamp("createdat");
		}
		ps.close();
		return ret;
	} catch (SQLException e) {
		throw new DatabaseException("error getting create", e);
	}
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:22,代码来源:MapleClient.java

示例14: buildMeta

import java.sql.Timestamp; //导入依赖的package包/类
private MetaWrapper buildMeta(MessageEntry msgEntry) {
    MetaWrapper metaWrapper = new MetaWrapper();
    EntryHeader header = msgEntry.getEntryHeader();
    RowData rowData = msgEntry.getMsgColumn().getRowDataLst().get(0);
    List<Column> columns = Support.getFinalColumns(header.getOperType(), rowData);
    for (Column column : columns) {
        MetaWrapper.MetaCell cell = new MetaWrapper.MetaCell();
        cell.setColumnName(column.getName());
        cell.setDataType(Support.getColumnType(column));
        int[] ret = Support.getColumnLengthAndPrecision(column);
        cell.setDataLength(ret[0]);
        cell.setDataPrecision(ret[1]);
        cell.setDataScale(0);
        cell.setIsPk(column.getIsKey() ? "Y" : "N");
        cell.setNullAble("N");
        cell.setDdlTime(new Timestamp(header.getExecuteTime()));
        cell.setColumnId(column.getIndex());
        cell.setInternalColumnId(column.getIndex());
        cell.setHiddenColumn("NO");
        cell.setVirtualColumn("NO");
        metaWrapper.addMetaCell(cell);
    }
    return metaWrapper;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:25,代码来源:MaDefaultHandler.java

示例15: insertPoint

import java.sql.Timestamp; //导入依赖的package包/类
private void insertPoint(Timestamp timestamp, Object value) throws Throwable {
    String sql = sourceGranularity == null
                 ? " INSERT INTO point (\"metric_id\", \"timestamp\", \"value\") VALUES (?, ?, ?) "
                 : " INSERT INTO point_" + sourceGranularity + " (\"metric_id\", \"timestamp\", \"value\", \"aggregation\") VALUES (?, ?, ?, ?) ";

    try (Connection connection = pugTSDB.getDataSource().getConnection();
         PreparedStatement statement = connection.prepareStatement(sql)) {
        statement.setInt(1, metric.getId());
        statement.setTimestamp(2, timestamp);
        statement.setBytes(3, metric.valueToBytes(value));

        if (sourceGranularity != null) {
            statement.setString(4, aggregation.getName());
        }

        statement.execute();
    }
}
 
开发者ID:StefaniniInspiring,项目名称:pugtsdb,代码行数:19,代码来源:RollUpAggregationSteps.java


注:本文中的java.sql.Timestamp类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。