当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.toLocalDateTime方法代码示例

本文整理汇总了Java中java.time.ZonedDateTime.toLocalDateTime方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.toLocalDateTime方法的具体用法?Java ZonedDateTime.toLocalDateTime怎么用?Java ZonedDateTime.toLocalDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.toLocalDateTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: bindArgs

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Binds arguments to prepared statement
 * @param stmt  the prepared statement reference
 * @return      the same as arg
 * @throws SQLException if binding fails
 */
private PreparedStatement bindArgs(PreparedStatement stmt) throws SQLException {
    for (int i=0; i<args.length; ++i) {
        final Object value = args[i];
        if      (value instanceof Boolean)          stmt.setBoolean(i+1, (Boolean)value);
        else if (value instanceof Short)            stmt.setShort(i+1, (Short)value);
        else if (value instanceof Integer)          stmt.setInt(i+1, (Integer)value);
        else if (value instanceof Float)            stmt.setFloat(i+1, (Float)value);
        else if (value instanceof Long)             stmt.setLong(i+1, (Long)value);
        else if (value instanceof Double)           stmt.setDouble(i+1, (Double)value);
        else if (value instanceof String)           stmt.setString(i+1, (String)value);
        else if (value instanceof java.sql.Date)    stmt.setDate(i+1, (java.sql.Date)value);
        else if (value instanceof Timestamp)        stmt.setTimestamp(i+1, (Timestamp)value);
        else if (value instanceof LocalDate)        stmt.setDate(i + 1, java.sql.Date.valueOf((LocalDate)value));
        else if (value instanceof LocalTime)        stmt.setTime(i+1, Time.valueOf((LocalTime)value));
        else if (value instanceof LocalDateTime)    stmt.setTimestamp(i+1, Timestamp.valueOf((LocalDateTime)value));
        else if (value instanceof ZonedDateTime) {
            final ZonedDateTime zonedDateTime = (ZonedDateTime)value;
            final LocalDateTime dateTime = zonedDateTime.toLocalDateTime();
            stmt.setTimestamp(i+1, Timestamp.valueOf(dateTime));
        } else {
            throw new RuntimeException("Unsupported argument, cannot be bound to SQL statement: " + value);
        }
    }
    return stmt;
}
 
开发者ID:zavtech,项目名称:morpheus-core,代码行数:32,代码来源:SQL.java

示例2: convertToDatabaseColumn

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public LocalDateTime convertToDatabaseColumn(ZonedDateTime entityValue) {
    return entityValue.toLocalDateTime();
}
 
开发者ID:javaee-samples,项目名称:javaee8-applications,代码行数:5,代码来源:LocalToZonedConverter.java

示例3: convert

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public LocalDateTime convert(ZonedDateTime source) {
	return source.toLocalDateTime();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:DateTimeConverters.java

示例4: vanXsdDatumTijdNaarDate

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Converteert een xsd-datum naar een {@link java.util.Date}.
 * @param datumTijd datumTijd
 * @return date
 */
public static Date vanXsdDatumTijdNaarDate(final String datumTijd) {
    final ZonedDateTime zonedDateTime = ZonedDateTime.parse(datumTijd, DateTimeFormatter.ISO_DATE_TIME).withZoneSameInstant(ZoneId.of(DatumUtil.UTC));
    final LocalDateTime toLocalDateTime = zonedDateTime.toLocalDateTime();
    return Date.from(toLocalDateTime.atZone(ZoneId.of(DatumUtil.UTC)).toInstant());
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:11,代码来源:DatumUtil.java

示例5: Interval

import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Constructs a new time interval with the given start and end zoned dates /
 * times. The time zone will be initialized with the time zone of the start
 * date time. However, if the zone ID of the second argument is different then
 * an exception will be thrown.
 *
 * @throws IllegalArgumentException if two different time zones are used
 *
 * @param zonedStartDateTime the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)
 * @param zonedEndDateTime   the end date and time
 */
public Interval(ZonedDateTime zonedStartDateTime, ZonedDateTime zonedEndDateTime) {
    this(zonedStartDateTime.toLocalDateTime(), zonedEndDateTime.toLocalDateTime(), zonedStartDateTime.getZone());

    if (!zonedStartDateTime.getZone().equals(zonedEndDateTime.getZone())) {
        throw new IllegalArgumentException("the zoned start and end times use different time zones, zone1 = " + zonedStartDateTime.getZone() +
                ", zone2 = " + zonedEndDateTime.getZone());
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:20,代码来源:Interval.java


注:本文中的java.time.ZonedDateTime.toLocalDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。