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


Java Timestamp.valueOf方法代码示例

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


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

示例1: delete

import java.sql.Timestamp; //导入方法依赖的package包/类
@Override
@CacheEvict(cacheNames = "employee", key = "#empID")
public void delete(int empID) {
    logger.info("Запрос к базе на удаление сотрудника с ID: " + empID);
    String hql =
            "update EmployeeHistory E set E.isActive = false, " +
                    "E.endDate = :currentTimestamp, E.isDeleted = true" +
                    " where (E.empID = :empID) and (E.isActive = :state)";
    Timestamp currentTime = Timestamp.valueOf(LocalDateTime.now());
    Session session = getSession();
    try{
        session.createQuery(hql)
                .setTimestamp("currentTimestamp", currentTime)
                .setInteger("empID", empID)
                .setBoolean("state", true)
                .executeUpdate();
    }catch (HibernateException e){
        logger.error(e.getStackTrace());
        throw new MyRuntimeException(StuffExceptions.DATABASE_ERROR);
    }
}
 
开发者ID:Witerium,项目名称:stuffEngine,代码行数:22,代码来源:HibernateEmployeeDao.java

示例2: test05

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test05() throws Exception {
    String testTS = "2009-1-01 10:50:0";
    String ExpectedTS = "2009-01-01 10:50:0";
    Timestamp ts = Timestamp.valueOf(testTS);
    Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
    assertEquals(ts, ts2, "Error ts1 != ts2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TimestampTests.java

示例3: createLayer

import java.sql.Timestamp; //导入方法依赖的package包/类
private static ILayer createLayer(String id, final String date, GeometryImage layer, ImageLayer parent) {
	String start=((SarImageReader)parent.getImageReader()).getTimeStampStart();
	start=start.replace("Z","");
	Timestamp t=Timestamp.valueOf(start);
    return new InterpolatedVectorLayer(layer.getName(),parent.getImageReader(), layer, id, date,t);

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:8,代码来源:AddInterpolatedConsoleAction.java

示例4: test51

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test(dataProvider = "validateNanos")
public void test51(String ts, int nanos) {
    Timestamp ts1 = Timestamp.valueOf(ts);
    Timestamp ts2 = Timestamp.valueOf(ts1.toString());
    assertTrue(ts1.getNanos() == nanos && ts1.equals(ts2),
            "Error with Nanos");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TimestampTests.java

示例5: test26

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test26() {
    Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
    Timestamp ts2 = new Timestamp(ts1.getTime() + 1000);
    assertTrue(ts1.compareTo(ts2) == -1, "Error ts1 not before ts2");
    assertTrue(ts2.compareTo(ts1) == 1, "Error ts1 is not before ts2");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TimestampTests.java

示例6: test45

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test45() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
    Instant instant = ts1.toInstant();
    Timestamp ts2 = Timestamp.from(instant);
    assertTrue(ts1.equals(ts2), "Error ts1 != ts2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TimestampTests.java

示例7: getDate

import java.sql.Timestamp; //导入方法依赖的package包/类
public static String getDate(){		
	Timestamp ts = null;
	
	try{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String d = sdf.format(new java.util.Date());
		ts = Timestamp.valueOf(d);
	}catch( Exception ex ){
		ex.printStackTrace();
	}
       
       return ts.toString().substring( 8, 10 );
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:14,代码来源:StrUtil.java

示例8: timestampValue

import java.sql.Timestamp; //导入方法依赖的package包/类
/**
 *  Converts a string in JDBC timestamp escape format to a
 *  <code>Timestamp</code> value.
 *
 * @param s timestamp in format <code>yyyy-mm-dd hh:mm:ss.fffffffff</code>
 *      where end part can be omitted, or "NOW" (case insensitive)
 * @return  corresponding <code>Timestamp</code> value
 * @exception java.lang.IllegalArgumentException if the given argument
 * does not have the format <code>yyyy-mm-dd hh:mm:ss.fffffffff</code>
 */
public static Timestamp timestampValue(String s) throws HsqlException {

    if (s == null) {
        throw Trace.error(Trace.HsqlDateTime_null_string);
    }

    if (s.length() > zerodatetime.length()) {
        throw Trace.error(Trace.STRING_DATA_TRUNCATION);
    }

    s = s + zerodatetime.substring(s.length());

    return Timestamp.valueOf(s);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:HsqlDateTime.java

示例9: test13

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test(dataProvider = "validTimestampValues")
public void test13(String ts, String expectedTS) {
    Timestamp ts1 = Timestamp.valueOf(ts);
    Timestamp ts2 = Timestamp.valueOf(ts1.toString());
    assertTrue(ts1.equals(ts2) && ts2.equals(ts1)
            && ts1.toString().equals(expectedTS), "Error ts1 != ts2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TimestampTests.java

示例10: test40

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test40() throws Exception {
    int nanos = 999999999;
    Timestamp ts1 = Timestamp.valueOf("1961-08-30 00:00:00");
    ts1.setNanos(nanos);
    assertTrue(ts1.getNanos() == nanos, "Error Invalid Nanos value");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TimestampTests.java

示例11: test03

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test03() throws Exception {
    String testTS = "2009-1-1 10:50:0";
    String ExpectedTS = "2009-01-01 10:50:0";
    Timestamp ts = Timestamp.valueOf(testTS);
    Timestamp ts2 = Timestamp.valueOf(ExpectedTS);
    assertEquals(ts, ts2, "Error ts1 != ts2");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TimestampTests.java

示例12: validateResults

import java.sql.Timestamp; //导入方法依赖的package包/类
private void validateResults(Map<String, Object> map, Integer aId,
        Integer bId, String stringField, String timestampField, Integer cId) throws Exception {

    assertEquals(aId, toInteger(map.get("A_ID")));
    assertEquals(bId, toInteger(map.get("B_ID")));
    assertEquals(stringField, map.get("STRING_FIELD"));
    Timestamp millis = timestampField == null ? null : Timestamp.valueOf(timestampField);
    assertEquals(millis, new OracleDbPlatform().getTimestampValue((map.get("TIMESTAMP_FIELD"))));
    assertEquals(cId, toInteger(map.get("C_ID")));
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:11,代码来源:OracleDeployIT.java

示例13: converteer

import java.sql.Timestamp; //导入方法依赖的package包/类
/**
 * Converteert een {@link ArchiveringOpdracht} naar een {@link Bericht}
 * @param opdracht de te converteren archivering opdracht
 * @return een bericht
 */
static Bericht converteer(final ArchiveringOpdracht opdracht) {
    final Bericht archiefBericht = new Bericht(opdracht.getRichting(), Timestamp.valueOf(opdracht.getTijdstipRegistratie().toLocalDateTime()));
    archiefBericht.setAdministratieveHandeling(opdracht.getAdministratieveHandelingId());
    archiefBericht.setBijhoudingResultaat(opdracht.getBijhoudingResultaat());
    archiefBericht.setCrossReferentieNummer(opdracht.getCrossReferentienummer());
    archiefBericht.setData(opdracht.getData());
    archiefBericht.setDienst(opdracht.getDienstId());
    if (opdracht.getHoogsteMeldingsNiveau() != null) {
        archiefBericht.setHoogsteMeldingsNiveau(opdracht.getHoogsteMeldingsNiveau());
    }
    archiefBericht.setLeveringsAutorisatie(opdracht.getLeveringsAutorisatieId());
    archiefBericht.setOntvangendePartij(opdracht.getOntvangendePartijId());
    archiefBericht.setReferentieNummer(opdracht.getReferentienummer());
    archiefBericht.setRol(opdracht.getRolId());
    if (opdracht.getSoortBericht() != null) {
        archiefBericht.setSoortBericht(opdracht.getSoortBericht());
    }
    if (opdracht.getSoortSynchronisatie() != null) {
        archiefBericht.setSoortSynchronisatie(opdracht.getSoortSynchronisatie());
    }

    opdracht.getTeArchiverenPersonen()
            .forEach(p -> archiefBericht.addPersoon(new BerichtPersoon(archiefBericht, p,
                    Timestamp.valueOf(archiefBericht.getDatumTijdRegistratie().toLocalDateTime()))));

    if (opdracht.getTijdstipOntvangst() != null) {
        archiefBericht.setDatumTijdOntvangst(Timestamp.valueOf(opdracht.getTijdstipOntvangst().toLocalDateTime()));
    }
    if (opdracht.getTijdstipVerzending() != null) {
        archiefBericht.setDatumTijdVerzending(Timestamp.valueOf(opdracht.getTijdstipVerzending().toLocalDateTime()));
    }
    if (opdracht.getVerwerkingsresultaat() != null) {
        archiefBericht.setVerwerkingsResultaat(opdracht.getVerwerkingsresultaat());
    }
    if (opdracht.getVerwerkingswijze() != null) {
        archiefBericht.setVerwerkingswijze(opdracht.getVerwerkingswijze());
    }
    archiefBericht.setZendendePartij(opdracht.getZendendePartijId());
    archiefBericht.setZendendeSysteem(opdracht.getZendendeSysteem());
    return archiefBericht;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:47,代码来源:ArchiveringOpdrachtConverteerder.java

示例14: testBaseParameters

import java.sql.Timestamp; //导入方法依赖的package包/类
@DataProvider(name = "testBaseParameters")
private Object[][] testBaseParameters() throws SQLException {
    Integer aInt = 1;
    Long aLong = Long.MAX_VALUE;
    Short aShort = Short.MIN_VALUE;
    BigDecimal bd = BigDecimal.ONE;
    Double aDouble = Double.MAX_VALUE;
    Date aDate = Date.valueOf(LocalDate.now());
    Time aTime = Time.valueOf(LocalTime.now());
    Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
    Calendar cal = Calendar.getInstance();
    Boolean aBoolean = true;
    Float aFloat = 1.5f;
    Byte aByte = 1;
    brs = new StubBaseRowSet();

    brs.setInt(1, aInt);
    brs.setString(2, query);
    brs.setLong(3, aLong);
    brs.setBoolean(4, aBoolean);
    brs.setShort(5, aShort);
    brs.setDouble(6, aDouble);
    brs.setBigDecimal(7, bd);
    brs.setFloat(8, aFloat);
    brs.setByte(9, aByte);
    brs.setDate(10, aDate);
    brs.setTime(11, aTime);
    brs.setTimestamp(12, aTimeStamp);
    brs.setDate(13, aDate, cal);
    brs.setTime(14, aTime, cal);
    brs.setTimestamp(15, aTimeStamp);
    brs.setObject(16, query);
    brs.setObject(17, query, Types.CHAR);
    brs.setObject(18, query, Types.CHAR, 0);

    return new Object[][]{
        {1, aInt},
        {2, query},
        {3, aLong},
        {4, aBoolean},
        {5, aShort},
        {6, aDouble},
        {7, bd},
        {8, aFloat},
        {9, aByte},
        {10, aDate},
        {11, aTime},
        {12, aTimeStamp},
        {13, aDate},
        {14, aTime},
        {15, aTimeStamp},
        {16, query},
        {17, query},
        {18, query}

    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:58,代码来源:BaseRowSetTests.java

示例15: test21

import java.sql.Timestamp; //导入方法依赖的package包/类
@Test
public void test21() {
    Timestamp ts1 = Timestamp.valueOf("1996-12-13 14:15:25.745634");
    Timestamp ts2 = Timestamp.valueOf("1996-11-13 15:15:25.645634");
    assertTrue(ts1.after(ts2), "Error ts1 not after ts2");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TimestampTests.java


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