本文整理了Java中java.sql.Date.toLocalDate()
方法的一些代码示例,展示了Date.toLocalDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.toLocalDate()
方法的具体详情如下:
包路径:java.sql.Date
类名称:Date
方法名:toLocalDate
暂无
代码示例来源:origin: requery/requery
@Override
public LocalDate convertToMapped(Class<? extends LocalDate> type, java.sql.Date value) {
if (value == null) {
return null;
}
return value.toLocalDate();
}
}
代码示例来源:origin: speedment/speedment
@Override
public LocalDate toJavaType(Column column, Class<?> entityType, Date value) {
return value.toLocalDate();
}
代码示例来源:origin: stackoverflow.com
Date date = r.getDate();
LocalDate localD = date.toLocalDate();
代码示例来源:origin: stackoverflow.com
LocalDate ld = new java.sql.Date(date.getTime()).toLocalDate();
代码示例来源:origin: stackoverflow.com
import java.time.LocalDate;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
@Converter
public class LocalDatePersistenceConverter implements AttributeConverter<LocalDate, java.sql.Date> {
@Override
public java.sql.Date convertToDatabaseColumn(LocalDate entityValue) {
if (entityValue != null) {
return java.sql.Date.valueOf(entityValue);
}
return null;
}
@Override
public LocalDate convertToEntityAttribute(java.sql.Date databaseValue) {
if (databaseValue != null) {
return databaseValue.toLocalDate();
}
return null;
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public LocalDate convertToEntityAttribute(Date date) {
return date == null ? null : date.toLocalDate();
}
}
代码示例来源:origin: debezium/debezium
/**
* Get the ISO 8601 formatted representation of the given {@link java.sql.Date}, which contains a date but no time or
* timezone information.
*
* @param date the date value; may not be null
* @param zoneId the timezone identifier or offset where the date 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.Date date, ZoneId zoneId, TemporalAdjuster adjuster) {
LocalDate localDate = date.toLocalDate();
if (adjuster != null) {
localDate = localDate.with(adjuster);
}
ZonedDateTime zdt = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, zoneId);
return zdt.format(FORMATTER);
}
代码示例来源:origin: debezium/debezium
/**
* Get the ISO 8601 formatted representation of the given {@link java.sql.Date}, which contains a date but no time or
* timezone information.
*
* @param date the date value
* @param zoneId the timezone identifier or offset where the date 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.Date date, ZoneId zoneId, TemporalAdjuster adjuster) {
LocalDate localDate = date.toLocalDate();
if (adjuster != null) {
localDate = localDate.with(adjuster);
}
ZonedDateTime zdt = ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, zoneId);
return zdt.format(FORMATTER);
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public <X> LocalDate wrap(X value, WrapperOptions options) {
if ( value == null ) {
return null;
}
if ( LocalDate.class.isInstance( value ) ) {
return (LocalDate) value;
}
if ( Timestamp.class.isInstance( value ) ) {
final Timestamp ts = (Timestamp) value;
return LocalDateTime.ofInstant( ts.toInstant(), ZoneId.systemDefault() ).toLocalDate();
}
if ( Long.class.isInstance( value ) ) {
final Instant instant = Instant.ofEpochMilli( (Long) value );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate();
}
if ( Calendar.class.isInstance( value ) ) {
final Calendar calendar = (Calendar) value;
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalDate();
}
if ( Date.class.isInstance( value ) ) {
if ( java.sql.Date.class.isInstance( value ) ) {
return ((java.sql.Date) value).toLocalDate();
}
else {
return Instant.ofEpochMilli( ((Date) value).getTime() ).atZone( ZoneId.systemDefault() ).toLocalDate();
}
}
throw unknownWrap( value.getClass() );
}
代码示例来源:origin: jtablesaw/tablesaw
@Override
public DateColumn appendObj(Object obj) {
if (obj == null) {
return appendMissing();
}
if (obj instanceof java.sql.Date) {
return append(((java.sql.Date) obj).toLocalDate());
}
if (obj instanceof LocalDate) {
return append((LocalDate) obj);
}
throw new IllegalArgumentException("Cannot append " + obj.getClass().getName() + " to DateColumn");
}
代码示例来源:origin: debezium/debezium
return ((java.sql.Date)obj).toLocalDate();
代码示例来源:origin: stackoverflow.com
return ((java.sql.Date) date).toLocalDate();
else
return Instant.ofEpochMilli(date.getTime()).atZone(zone).toLocalDate();
代码示例来源:origin: debezium/debezium
LocalDate date = sqlDate.toLocalDate();
return LocalDateTime.of(date, LocalTime.MIDNIGHT);
代码示例来源:origin: spring-projects/spring-framework
protected void verifyPerson(DatePerson bean) {
assertEquals("Bubba", bean.getLastName());
assertEquals(22L, bean.getAge());
assertEquals(new java.sql.Date(1221222L).toLocalDate(), bean.getBirthDate());
assertEquals(new BigDecimal("1234.56"), bean.getBalance());
}
代码示例来源:origin: ebean-orm/ebean
@Override
public LocalDate toBeanType(Object value) {
if (value instanceof java.sql.Date) {
return ((java.sql.Date) value).toLocalDate();
}
return (LocalDate) value;
}
代码示例来源:origin: debezium/debezium
} else if ( obj instanceof java.sql.Date ){
java.sql.Date date = (java.sql.Date)obj;
append(DateTimeFormatter.ISO_DATE.format(date.toLocalDate()));
} else if ( obj instanceof java.sql.Timestamp ){
java.sql.Timestamp ts = (java.sql.Timestamp)obj;
代码示例来源:origin: org.postgresql/postgresql
return type.cast(LocalDate.MIN);
return type.cast(dateValue.toLocalDate());
} else if (sqlType == Types.TIMESTAMP) {
LocalDateTime localDateTimeValue = getLocalDateTime(columnIndex);
代码示例来源:origin: ebean-orm/ebean
@Override
public YearMonth toBeanType(Object value) {
if (value instanceof YearMonth) return (YearMonth) value;
if (value instanceof LocalDate) return fromLocalDate((LocalDate) value);
if (value == null) return null;
return fromLocalDate(BasicTypeConverter.toDate(value).toLocalDate());
}
代码示例来源: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 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")));
}
内容来源于网络,如有侵权,请联系作者删除!