本文整理了Java中java.sql.Timestamp.getYear()
方法的一些代码示例,展示了Timestamp.getYear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.getYear()
方法的具体详情如下:
包路径:java.sql.Timestamp
类名称:Timestamp
方法名:getYear
暂无
代码示例来源:origin: robovm/robovm
StringBuilder sb = new StringBuilder(29);
format((getYear() + 1900), 4, sb);
sb.append('-');
format((getMonth() + 1), 2, sb);
代码示例来源:origin: debezium/debezium
return LocalDateTime.of(timestamp.getYear() + 1900,
timestamp.getMonth() + 1,
timestamp.getDate(),
代码示例来源:origin: oblac/jodd
assertEquals(FooWeight.light, foo.weight);
assertNotNull(foo.timestamp);
assertEquals(109, foo.timestamp.getYear());
assertEquals(6, foo.timestamp.getHours());
assertEquals(5, foo.timestamp.getMinutes());
assertEquals(FooColor.yellow, foo.color);
assertEquals(FooWeight.heavy, foo.weight);
assertEquals(108, foo.timestamp.getYear());
assertEquals(2010, foo.timestamp2.getYear());
assertEquals(20, foo.timestamp2.getHour());
代码示例来源:origin: apache/phoenix
@Test
public void testCurrentTimeWithProjectedTable () throws Exception {
String tableName1 = generateUniqueName();
String tableName2 = generateUniqueName();
String ddl = "CREATE TABLE " + tableName1 + " ( ID integer primary key)";
conn.createStatement().execute(ddl);
ddl = "CREATE TABLE " + tableName2 + " ( ID integer primary key)";
conn.createStatement().execute(ddl);
String ups = "UPSERT INTO " + tableName1 + " VALUES (1)";
conn.createStatement().execute(ups);
ups = "UPSERT INTO " + tableName2 + " VALUES (1)";
conn.createStatement().execute(ups);
conn.commit();
ResultSet rs = conn.createStatement().executeQuery("select /*+ USE_SORT_MERGE_JOIN */ op" +
".id, current_time() from " +tableName1 + " op where op.id in (select id from " + tableName2 + ")");
assertTrue(rs.next());
assertEquals(new java.util.Date().getYear(),rs.getTimestamp(2).getYear());
}
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
Assert.assertEquals(sqlTimestamp.getMinutes(), s.getSqlTimestamp().getMinutes());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
Assert.assertEquals(sqlTimestamp.getMinutes(), s.getSqlTimestamp().getMinutes());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
Assert.assertEquals(sqlTimestamp.getMinutes(), s.getSqlTimestamp().getMinutes());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
Assert.assertEquals(sqlTimestamp.getMinutes(), s.getSqlTimestamp().getMinutes());
代码示例来源:origin: stackoverflow.com
Timestamp begin = entry.getPeriodBegin()
Timestamp end = entry.getPeriodEnd()
if (begin.getYear() != end.getYear() || begin.getMonth() != end.getMonth() || begin.getDay() != end.getDay() ....)
代码示例来源:origin: waterguo/antsdb
@SuppressWarnings("deprecation")
@Override
public long eval(VdmContext ctx, Heap heap, Parameters params, long pRecord) {
long pValue = this.parameters.get(0).eval(ctx, heap, params, pRecord);
if (pValue == 0) {
return 0;
}
pValue = AutoCaster.toTimestamp(heap, pValue);
Timestamp ts = FishTimestamp.get(heap, pValue);
return Int4.allocSet(heap, ts.getYear() + 1900);
}
代码示例来源:origin: MobiVM/robovm
StringBuilder sb = new StringBuilder(29);
format((getYear() + 1900), 4, sb);
sb.append('-');
format((getMonth() + 1), 2, sb);
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings("deprecation")
private Timestamp withTZ(Timestamp timestamp, Calendar cal) {
if (timestamp == null)
return null;
int year = timestamp.getYear() + 1900;
int month = timestamp.getMonth();
int day = timestamp.getDate();
int hour = timestamp.getHours();
int minute = timestamp.getMinutes();
int second = timestamp.getSeconds();
int nanos = timestamp.getNanos();
int millis = nanos / 1000000;
nanos = nanos - millis * 1000000;
Timestamp r = new Timestamp(getMillis(cal, year, month, day, hour, minute, second, millis));
r.setNanos(nanos + millis * 1000000);
return r;
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Converts a {@code java.sql.Timestamp} to a {@code LocalDateTime}.
*
* @param sqlTimestamp the SQL timestamp, not null
* @return the local date-time, not null
*/
@SuppressWarnings("deprecation")
public static LocalDateTime toLocalDateTime(Timestamp sqlTimestamp) {
return LocalDateTime.of(
sqlTimestamp.getYear() + 1900,
sqlTimestamp.getMonth() + 1,
sqlTimestamp.getDate(),
sqlTimestamp.getHours(),
sqlTimestamp.getMinutes(),
sqlTimestamp.getSeconds(),
sqlTimestamp.getNanos());
}
代码示例来源:origin: com.gluonhq/robovm-rt
StringBuilder sb = new StringBuilder(29);
format((getYear() + 1900), 4, sb);
sb.append('-');
format((getMonth() + 1), 2, sb);
代码示例来源:origin: com.bugvm/bugvm-rt
StringBuilder sb = new StringBuilder(29);
format((getYear() + 1900), 4, sb);
sb.append('-');
format((getMonth() + 1), 2, sb);
代码示例来源:origin: embulk/embulk-input-jdbc
@Override
public JsonNode encodeToJson()
{
String text = String.format(ENGLISH,
ISO_USEC_FORMAT,
dateTime.getYear() + 1900,
dateTime.getMonth() + 1,
dateTime.getDate(),
dateTime.getHours(),
dateTime.getMinutes(),
dateTime.getSeconds(),
dateTime.getNanos() / 1000);
return jsonNodeFactory.textNode(text);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code java.sql.Timestamp} to a {@code LocalDateTime}.
*
* @param sqlTimestamp the SQL timestamp, not null
* @return the local date-time, not null
*/
@SuppressWarnings("deprecation")
public static LocalDateTime toLocalDateTime(Timestamp sqlTimestamp) {
return LocalDateTime.of(
sqlTimestamp.getYear() + 1900,
sqlTimestamp.getMonth() + 1,
sqlTimestamp.getDate(),
sqlTimestamp.getHours(),
sqlTimestamp.getMinutes(),
sqlTimestamp.getSeconds(),
sqlTimestamp.getNanos());
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code java.sql.Timestamp} to a {@code LocalDateTime}.
*
* @param sqlTimestamp the SQL timestamp, not null
* @return the local date-time, not null
*/
@SuppressWarnings("deprecation")
public static LocalDateTime toLocalDateTime(Timestamp sqlTimestamp) {
return LocalDateTime.of(
sqlTimestamp.getYear() + 1900,
sqlTimestamp.getMonth() + 1,
sqlTimestamp.getDate(),
sqlTimestamp.getHours(),
sqlTimestamp.getMinutes(),
sqlTimestamp.getSeconds(),
sqlTimestamp.getNanos());
}
代码示例来源:origin: cascading/lingual-core
@Test
public void testSymmetricTimestampCoercion()
{
Object canonical = sqlTimestampCoercibleType.canonical( inputTimestamp );
Timestamp coerced = (Timestamp) sqlTimestampCoercibleType.coerce( canonical, java.sql.Timestamp.class );
// multiple coercions should preserve date. Run it 24 times to catch any timezone issue.
for( int i = 0; i < 24; i++ )
{
canonical = sqlTimestampCoercibleType.canonical( coerced );
assertEquals( "Canonical value changed on iteration " + i, timeAsLong, ( (Long) canonical ).longValue() );
coerced = (Timestamp) sqlTimestampCoercibleType.coerce( canonical, java.sql.Timestamp.class );
assertEquals( "Coerced day changed on iteration " + i + " now: " + coerced.toString(), inputTimestamp.getDate(), coerced.getDate() );
assertEquals( "Coerced month changed on iteration " + i + " now: " + coerced.toString(), inputTimestamp.getMonth(), coerced.getMonth() );
assertEquals( "Coerced year changed on iteration " + i + " now: " + coerced.toString(), inputTimestamp.getYear(), coerced.getYear() );
assertEquals( "Coerced hour changed on iteration " + i + " now: " + coerced.toString(), inputTimestamp.getHours(), coerced.getHours() );
}
}
代码示例来源:origin: cascading/lingual-core
@Test
public void testTimestampFromStringCoercion()
{
// as run in tests we go from UTC to local time by coercing.
String dateAsString = "1996-08-04 01:02:03";
Long canonical = (Long) sqlTimestampCoercibleType.canonical( dateAsString );
Timestamp coerced = (Timestamp) sqlTimestampCoercibleType.coerce( canonical, java.sql.Timestamp.class );
assertEquals( "String parsing got wrong day", 4, coerced.getDate() );
assertEquals( "String parsing got wrong month", 7, coerced.getMonth() );
assertEquals( "String parsing got wrong year", 96, coerced.getYear() );
assertEquals( "String parsing got wrong hour", 1, coerced.getHours() );
assertEquals( "String parsing got wrong minute", 2, coerced.getMinutes());
assertEquals( "String parsing got wrong second", 3, coerced.getSeconds() );
}
内容来源于网络,如有侵权,请联系作者删除!