本文整理了Java中java.sql.Timestamp.getMonth()
方法的一些代码示例,展示了Timestamp.getMonth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timestamp.getMonth()
方法的具体详情如下:
包路径:java.sql.Timestamp
类名称:Timestamp
方法名:getMonth
暂无
代码示例来源:origin: robovm/robovm
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 2, sb);
代码示例来源:origin: debezium/debezium
java.sql.Timestamp timestamp = (java.sql.Timestamp)obj;
return LocalDateTime.of(timestamp.getYear() + 1900,
timestamp.getMonth() + 1,
timestamp.getDate(),
timestamp.getHours(),
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getMonth(), s.getSqlTimestamp().getMonth());
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getMonth(), s.getSqlTimestamp().getMonth());
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getMonth(), s.getSqlTimestamp().getMonth());
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
代码示例来源:origin: Impetus/Kundera
Assert.assertEquals(sqlTimestamp.getMonth(), s.getSqlTimestamp().getMonth());
Assert.assertEquals(sqlTimestamp.getYear(), s.getSqlTimestamp().getYear());
Assert.assertEquals(sqlTimestamp.getHours(), s.getSqlTimestamp().getHours());
代码示例来源: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.getMonth()+1);
}
代码示例来源: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: MobiVM/robovm
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 2, sb);
代码示例来源: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
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 2, sb);
代码示例来源:origin: com.bugvm/bugvm-rt
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 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: ibinti/bugvm
format((getMonth() + 1), 2, sb);
sb.append('-');
format(getDate(), 2, sb);
代码示例来源: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: waterguo/antsdb
@SuppressWarnings("deprecation")
public static long toDate(Heap heap, long pValue) {
if (pValue == 0) {
return 0;
}
int type = Value.getType(heap, pValue);
Date result;
if (type == Value.TYPE_DATE) {
return pValue;
}
else if (type == Value.TYPE_TIMESTAMP) {
Timestamp value = FishTimestamp.get(heap, pValue);
result = new Date(value.getYear(), value.getMonth(), value.getDate());
}
else if (type == Value.TYPE_STRING) {
String text = (String)FishObject.get(heap, pValue);
result = parseDate(text);
if (result == null) {
throw new OrcaException("invalid date value: " + text);
}
}
else if (type == Value.TYPE_BYTES) {
pValue = toString(heap, pValue);
return toDate(heap, pValue);
}
else {
throw new IllegalArgumentException();
}
return FishObject.allocSet(heap, result);
}
代码示例来源: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() );
}
内容来源于网络,如有侵权,请联系作者删除!