本文整理了Java中java.time.OffsetDateTime.toLocalDate()
方法的一些代码示例,展示了OffsetDateTime.toLocalDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.toLocalDate()
方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:toLocalDate
[英]Gets the LocalDate part of this date-time.
This returns a LocalDate with the same year, month and day as this date-time.
[中]获取此日期时间的LocalDate部分。
这将返回一个LocalDate,其年份、月份和日期与此日期时间相同。
代码示例来源:origin: spring-projects/spring-framework
@Override
public LocalDate convert(OffsetDateTime source) {
return source.toLocalDate();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public LocalDate convert(OffsetDateTime source) {
return source.toLocalDate();
}
}
代码示例来源:origin: apache/storm
int dateInt = (int) timestamp.toLocalDateTime().atOffset(ZoneOffset.UTC).toLocalDate().toEpochDay();
int localTimeInt = (int) (localTimestamp % DateTimeUtils.MILLIS_PER_DAY);
int currentTimeInt = (int) (currentTimestamp % DateTimeUtils.MILLIS_PER_DAY);
代码示例来源:origin: stackoverflow.com
public static final long nextDayStartSec(long epochSecondsInUTC) {
OffsetDateTime odt = Instant.ofEpochSecond(epochSecondsInUTC).atOffset(ZoneOffset.UTC);
return odt.toLocalDate().plusDays(1).atStartOfDay(ZoneOffset.UTC).toEpochSecond();
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public LocalDate convert(OffsetDateTime source) {
return source.toLocalDate();
}
}
代码示例来源:origin: stackoverflow.com
import java.time.OffsetDateTime;
public class SQLDateTest {
public static void main(String[] args){
Date d = java.sql.Date.valueOf(OffsetDateTime.parse("0123-12-27T00:00:00.000+01:00").toLocalDate());
System.out.println(d);
}
}
代码示例来源:origin: stackoverflow.com
// Parser
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS Z");
// Parse date/time with time zone
// OffsetDateTime odtWithTime = OffsetDateTime.parse("2011/02/14 00:00:00.000 -0800", formatter);
OffsetDateTime odtWithTime = OffsetDateTime.parse("2011/02/14 09:30:00.999 -0800", formatter);
// odtWithTime: 2011-02-14T09:30:00.999-08:00
// Remove time from odtWithTime
LocalDateTime ldtWithoutTime = odtWithTime.toLocalDate().atStartOfDay();
OffsetDateTime odtWihtoutTime = OffsetDateTime.of(ldtWithoutTime, odtWithTime.getOffset());
// odtWihtoutTime: 2011-02-14T00:00-08:00
// All time information are reset to Zero
代码示例来源:origin: platonai/pulsar
public static boolean isDaysBefore(OffsetDateTime dateTime, int days) {
if (dateTime != null) {
// ZonedDateTime ldt = date.atZone(ZoneId.systemDefault());
if (CURRENT_DATE_EPOCH_DAYS - dateTime.toLocalDate().toEpochDay() > days) {
return true;
}
}
return false;
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Gets the inclusive temporal start date of this period of time.
*
* If the period is in days, then the returned temporal is a {@link LocalDate} which represents
* the first day of the period.<br>
* Otherwise, the date and the time in UTC/Greenwich at which this period starts on the
* timeline is returned.
* @return a temporal instance ({@link LocalDate} if all day period or {@link OffsetDateTime})
* otherwise.
*/
public Temporal getStartDate() {
return isInDays() ? startDateTime.toLocalDate() : startDateTime;
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Gets the end date of the recurrence. The end date of the recurrence can be unspecified, in that
* case the returned end date is empty.
* @return an optional recurrence end date. The optional is empty if the end date of the
* recurrence is unspecified, otherwise the recurrence termination date or datetime can be get
* from the {@link Optional}. The returned datetime is from UTC/Greenwich.
*/
public Optional<Temporal> getRecurrenceEndDate() {
if (this.endDateTime != NO_RECURRENCE_END_DATE) {
return Optional.of(
getStartDate() instanceof LocalDate ? this.endDateTime.toLocalDate() : this.endDateTime);
}
return Optional.empty();
}
代码示例来源:origin: Silverpeas/Silverpeas-Core
/**
* Gets the exclusive temporal end date of this period of time.
*
* If the period is in days, then the returned temporal is a {@link LocalDate} which represents
* the last day of the period.<br>
* Otherwise, the date and the time in UTC/Greenwich at which this period ends on the
* timeline is returned.
* @return a temporal instance ({@link LocalDate} if all day period or {@link OffsetDateTime})
* otherwise.
*/
public Temporal getEndDate() {
return isInDays() ? endDateTime.toLocalDate() : endDateTime;
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor
/**
*
*/
@Override
protected Scheduler scheduler() {
OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
return Scheduler.newFixedRateSchedule(
Duration.between(now, OffsetDateTime.of(now.toLocalDate().plusDays(1).atStartOfDay(), ZoneOffset.UTC)).getSeconds(),
Duration.ofDays(1).getSeconds(), TimeUnit.SECONDS);
}
}
代码示例来源:origin: com.github.robozonky/robozonky-app
private static List<Development> getDevelopments(final Tenant auth, final int loanId,
final LocalDate delinquentSince) {
final LocalDate lastNonDelinquentDay = delinquentSince.minusDays(1);
final List<Development> developments = auth.call(z -> z.getDevelopments(loanId))
.filter(d -> d.getDateFrom().toLocalDate().isAfter(lastNonDelinquentDay))
.collect(toList());
Collections.reverse(developments);
return developments;
}
代码示例来源:origin: RoboZonky/robozonky
private static List<Development> getDevelopments(final Tenant auth, final int loanId,
final LocalDate delinquentSince) {
final LocalDate lastNonDelinquentDay = delinquentSince.minusDays(1);
final List<Development> developments = auth.call(z -> z.getDevelopments(loanId))
.filter(d -> d.getDateFrom().toLocalDate().isAfter(lastNonDelinquentDay))
.collect(toList());
Collections.reverse(developments);
return developments;
}
代码示例来源:origin: bazaarvoice/emodb
/**
*
*/
@Override
protected Scheduler scheduler() {
OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
return Scheduler.newFixedRateSchedule(
Duration.between(now, OffsetDateTime.of(now.toLocalDate().plusDays(1).atStartOfDay(), ZoneOffset.UTC)).getSeconds(),
Duration.ofDays(1).getSeconds(), TimeUnit.SECONDS);
}
}
代码示例来源:origin: oracle/pgql-lang
protected static String printLiteral(OffsetDateTime val) {
return "TIMESTAMP '" + val.toLocalDate() + " " + printTime(val.toLocalTime()) + val.getOffset() + "'";
}
}
代码示例来源:origin: com.esotericsoftware/kryo
public void write (Kryo kryo, Output out, OffsetDateTime obj) {
LocalDateSerializer.write(out, obj.toLocalDate());
LocalTimeSerializer.write(out, obj.toLocalTime());
ZoneOffsetSerializer.write(out, obj.getOffset());
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void write (Kryo kryo, Output out, OffsetDateTime obj) {
LocalDateSerializer.write(out, obj.toLocalDate());
LocalTimeSerializer.write(out, obj.toLocalTime());
ZoneOffsetSerializer.write(out, obj.getOffset());
}
代码示例来源:origin: pl.touk.esp/esp-process
public void write(Kryo kryo, Output out, OffsetDateTime obj) {
LocalDateSerializer.write(out, obj.toLocalDate());
LocalTimeSerializer.write(out, obj.toLocalTime());
ZoneOffsetSerializer.write(out, obj.getOffset());
}
代码示例来源:origin: Netflix/iceberg
@Override
@SuppressWarnings("unchecked")
public <T> Literal<T> to(Type type) {
switch (type.typeId()) {
case TIMESTAMP:
return (Literal<T>) this;
case DATE:
return (Literal<T>) new DateLiteral((int) ChronoUnit.DAYS.between(
EPOCH_DAY, EPOCH.plus(value(), ChronoUnit.MICROS).toLocalDate()));
default:
}
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!