本文整理汇总了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;
}
示例2: convertToDatabaseColumn
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public LocalDateTime convertToDatabaseColumn(ZonedDateTime entityValue) {
return entityValue.toLocalDateTime();
}
示例3: convert
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public LocalDateTime convert(ZonedDateTime source) {
return source.toLocalDateTime();
}
示例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());
}
示例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());
}
}