本文整理汇总了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);
}
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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 );
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}
示例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")));
}
示例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;
}
示例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}
};
}
示例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");
}