本文整理了Java中java.sql.Time.toLocalTime()
方法的一些代码示例,展示了Time.toLocalTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.toLocalTime()
方法的具体详情如下:
包路径:java.sql.Time
类名称:Time
方法名:toLocalTime
暂无
代码示例来源:origin: requery/requery
@Override
public LocalTime convertToMapped(Class<? extends LocalTime> type, java.sql.Time value) {
if (value == null) {
return null;
}
return value.toLocalTime();
}
}
代码示例来源:origin: speedment/speedment
@Override
public LocalTime toJavaType(Column column, Class<?> entityType, Time value) {
return value.toLocalTime();
}
代码示例来源:origin: jdbi/jdbi
private static LocalTime getLocalTime(ResultSet r, int i) throws SQLException {
Time time = r.getTime(i);
return time == null ? null : time.toLocalTime();
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public LocalTime convertToEntityAttribute(Time time) {
return time == null ? null : time.toLocalTime();
}
}
代码示例来源:origin: debezium/debezium
/**
* Get the ISO 8601 formatted representation of the given {@link java.sql.Time}, which contains time but no date or timezone
* information.
*
* @param time the JDBC time value; may not be null
* @param zoneId the timezone identifier or offset where the time is defined
* @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
* adjustment is necessary
* @return the ISO 8601 formatted string
*/
public static String toIsoString(java.sql.Time time, ZoneId zoneId, TemporalAdjuster adjuster) {
LocalTime localTime = time.toLocalTime();
if (adjuster != null) {
localTime = localTime.with(adjuster);
}
ZonedDateTime zdt = ZonedDateTime.of(Conversions.EPOCH, localTime, zoneId);
return zdt.format(FORMATTER);
}
代码示例来源:origin: debezium/debezium
/**
* Get the ISO 8601 formatted representation of the given {@link java.sql.Time}, which contains time but no date or timezone
* information.
*
* @param time the JDBC time value
* @param zoneId the timezone identifier or offset where the time is defined
* @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
* adjustment is necessary
* @return the ISO 8601 formatted string
*/
public static String toIsoString(java.sql.Time time, ZoneId zoneId, TemporalAdjuster adjuster) {
LocalTime localTime = time.toLocalTime();
if (adjuster != null) {
localTime = localTime.with(adjuster);
}
ZonedDateTime zdt = ZonedDateTime.of(Conversions.EPOCH, localTime, zoneId);
return zdt.format(FORMATTER);
}
代码示例来源:origin: hibernate/hibernate-orm
return ( (Time) value ).toLocalTime().atOffset( OffsetDateTime.now().getOffset() );
代码示例来源:origin: prestodb/presto
@Test
public void testLocallyUnrepresentableTimeLiterals()
{
LocalDateTime localTimeThatDidNotExist = LocalDateTime.of(2017, 4, 2, 2, 10);
checkState(ZoneId.systemDefault().getRules().getValidOffsets(localTimeThatDidNotExist).isEmpty(), "This test assumes certain JVM time zone");
// This tests that both Presto runner and H2 can return TIMESTAMP value that never happened in JVM's zone (e.g. is not representable using java.sql.Timestamp)
@Language("SQL") String sql = DateTimeFormatter.ofPattern("'SELECT TIMESTAMP '''uuuu-MM-dd HH:mm:ss''").format(localTimeThatDidNotExist);
assertEquals(computeScalar(sql), localTimeThatDidNotExist); // this tests Presto and the QueryRunner
assertQuery(sql); // this tests H2QueryRunner
LocalDate localDateThatDidNotHaveMidnight = LocalDate.of(1970, 1, 1);
checkState(ZoneId.systemDefault().getRules().getValidOffsets(localDateThatDidNotHaveMidnight.atStartOfDay()).isEmpty(), "This test assumes certain JVM time zone");
// This tests that both Presto runner and H2 can return DATE value for a day which midnight never happened in JVM's zone (e.g. is not exactly representable using java.sql.Date)
sql = DateTimeFormatter.ofPattern("'SELECT DATE '''uuuu-MM-dd''").format(localDateThatDidNotHaveMidnight);
assertEquals(computeScalar(sql), localDateThatDidNotHaveMidnight); // this tests Presto and the QueryRunner
assertQuery(sql); // this tests H2QueryRunner
LocalTime localTimeThatDidNotOccurOn19700101 = LocalTime.of(0, 10);
checkState(ZoneId.systemDefault().getRules().getValidOffsets(localTimeThatDidNotOccurOn19700101.atDate(LocalDate.ofEpochDay(0))).isEmpty(), "This test assumes certain JVM time zone");
checkState(!Objects.equals(java.sql.Time.valueOf(localTimeThatDidNotOccurOn19700101).toLocalTime(), localTimeThatDidNotOccurOn19700101), "This test assumes certain JVM time zone");
sql = DateTimeFormatter.ofPattern("'SELECT TIME '''HH:mm:ss''").format(localTimeThatDidNotOccurOn19700101);
assertEquals(computeScalar(sql), localTimeThatDidNotOccurOn19700101); // this tests Presto and the QueryRunner
assertQuery(sql); // this tests H2QueryRunner
}
}
代码示例来源:origin: debezium/debezium
} else if ( obj instanceof java.sql.Time ){
java.sql.Time time = (java.sql.Time)obj;
append(DateTimeFormatter.ISO_LOCAL_TIME.format(time.toLocalTime()));
} else if ( obj instanceof java.sql.Date ){
java.sql.Date date = (java.sql.Date)obj;
代码示例来源:origin: org.mybatis/mybatis
private static LocalTime getLocalTime(Time time) {
if (time != null) {
return time.toLocalTime();
}
return null;
}
}
代码示例来源:origin: debezium/debezium
LocalTime localTime = Time.valueOf("00:00:00").toLocalTime();
java.util.Date date = new java.util.Date(Timestamp.toEpochMillis(localTime, MySqlValueConverters::adjustTemporal));
assertThat(schemaG.defaultValue()).isEqualTo(date);
代码示例来源:origin: ebean-orm/ebean
@Override
public LocalTime read(DataReader dataReader) throws SQLException {
Time time = dataReader.getTime();
return (time == null) ? null : time.toLocalTime();
}
代码示例来源:origin: ebean-orm/ebean
@Override
public LocalTime toBeanType(Object value) {
if (value instanceof LocalTime) return (LocalTime) value;
if (value == null) return null;
return BasicTypeConverter.toTime(value).toLocalTime();
}
代码示例来源:origin: rakam-io/rakam
case TIME:
Time time = resultSet.getTime(columnIndex);
object = time != null ? time.toLocalTime() : null;
break;
case BINARY:
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
return ((java.sql.Time)value).toLocalTime();
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testLoadJdbcSelect() throws Exception {
testCall(db, "CALL apoc.load.jdbc('jdbc:derby:derbyDB','SELECT * FROM PERSON')",
(row) -> assertEquals( Util.map("NAME", "John", "HIRE_DATE", hireDate.toLocalDate(),"EFFECTIVE_FROM_DATE",
effectiveFromDate.toLocalDateTime(), "TEST_TIME", time.toLocalTime(), "NULL_DATE", null), row.get("row")));
}
@Test
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testLoadJdbc() throws Exception {
testCall(db, "CALL apoc.load.jdbc('jdbc:derby:derbyDB','PERSON')",
(row) -> assertEquals( Util.map("NAME", "John", "HIRE_DATE", hireDate.toLocalDate(), "EFFECTIVE_FROM_DATE",
effectiveFromDate.toLocalDateTime(), "TEST_TIME", time.toLocalTime(), "NULL_DATE", null), row.get("row")));
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testLoadJdbcParams() throws Exception {
testCall(db, "CALL apoc.load.jdbc('jdbc:derby:derbyDB','SELECT * FROM PERSON WHERE NAME = ?',['John'])", // YIELD row RETURN row
(row) -> assertEquals( Util.map("NAME", "John",
"HIRE_DATE", hireDate.toLocalDate(),
"EFFECTIVE_FROM_DATE", effectiveFromDate.toLocalDateTime(),
"TEST_TIME", time.toLocalTime(),
"NULL_DATE", null), row.get("row")));
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testLoadJdbcKey() throws Exception {
testCall(db, "CALL apoc.load.jdbc('derby','PERSON')",
(row) -> assertEquals( Util.map("NAME", "John",
"HIRE_DATE", hireDate.toLocalDate(),
"EFFECTIVE_FROM_DATE", effectiveFromDate.toLocalDateTime(),
"TEST_TIME", time.toLocalTime(),
"NULL_DATE", null), row.get("row")));
}
代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures
@Test
public void testLoadJdbcParamsWithConfigLocalDateTime() throws Exception {
testCall(db, "CALL apoc.load.jdbc('jdbc:derby:derbyDB','SELECT * FROM PERSON WHERE NAME = ?',['John'])",
(row) -> assertEquals( Util.map("NAME", "John", "HIRE_DATE", hireDate.toLocalDate(), "EFFECTIVE_FROM_DATE",
effectiveFromDate.toLocalDateTime(), "TEST_TIME", time.toLocalTime(), "NULL_DATE", null), row.get("row")));
ZoneId asiaTokio = ZoneId.of("Asia/Tokyo");
testCall(db, "CALL apoc.load.jdbc('jdbc:derby:derbyDB','SELECT * FROM PERSON WHERE NAME = ?',['John'], {config})",
map("config", map("timezone", asiaTokio.toString())),
(row) -> {
assertEquals( Util.map("NAME", "John",
"HIRE_DATE", hireDate.toLocalDate(),
"EFFECTIVE_FROM_DATE", effectiveFromDate.toInstant().atZone(asiaTokio).toOffsetDateTime(),
"TEST_TIME", time.toLocalTime(),
"NULL_DATE", null), row.get("row"));
});
}
内容来源于网络,如有侵权,请联系作者删除!