java.time.OffsetDateTime.toLocalDate()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中java.time.OffsetDateTime.toLocalDate()方法的一些代码示例,展示了OffsetDateTime.toLocalDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.toLocalDate()方法的具体详情如下:
包路径:java.time.OffsetDateTime
类名称:OffsetDateTime
方法名:toLocalDate

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

  1. @Override
  2. public LocalDate convert(OffsetDateTime source) {
  3. return source.toLocalDate();
  4. }
  5. }

代码示例来源:origin: org.springframework/spring-context

  1. @Override
  2. public LocalDate convert(OffsetDateTime source) {
  3. return source.toLocalDate();
  4. }
  5. }

代码示例来源:origin: apache/storm

  1. int dateInt = (int) timestamp.toLocalDateTime().atOffset(ZoneOffset.UTC).toLocalDate().toEpochDay();
  2. int localTimeInt = (int) (localTimestamp % DateTimeUtils.MILLIS_PER_DAY);
  3. int currentTimeInt = (int) (currentTimestamp % DateTimeUtils.MILLIS_PER_DAY);

代码示例来源:origin: stackoverflow.com

  1. public static final long nextDayStartSec(long epochSecondsInUTC) {
  2. OffsetDateTime odt = Instant.ofEpochSecond(epochSecondsInUTC).atOffset(ZoneOffset.UTC);
  3. return odt.toLocalDate().plusDays(1).atStartOfDay(ZoneOffset.UTC).toEpochSecond();
  4. }

代码示例来源:origin: apache/servicemix-bundles

  1. @Override
  2. public LocalDate convert(OffsetDateTime source) {
  3. return source.toLocalDate();
  4. }
  5. }

代码示例来源:origin: stackoverflow.com

  1. import java.time.OffsetDateTime;
  2. public class SQLDateTest {
  3. public static void main(String[] args){
  4. Date d = java.sql.Date.valueOf(OffsetDateTime.parse("0123-12-27T00:00:00.000+01:00").toLocalDate());
  5. System.out.println(d);
  6. }
  7. }

代码示例来源:origin: stackoverflow.com

  1. // Parser
  2. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS Z");
  3. // Parse date/time with time zone
  4. // OffsetDateTime odtWithTime = OffsetDateTime.parse("2011/02/14 00:00:00.000 -0800", formatter);
  5. OffsetDateTime odtWithTime = OffsetDateTime.parse("2011/02/14 09:30:00.999 -0800", formatter);
  6. // odtWithTime: 2011-02-14T09:30:00.999-08:00
  7. // Remove time from odtWithTime
  8. LocalDateTime ldtWithoutTime = odtWithTime.toLocalDate().atStartOfDay();
  9. OffsetDateTime odtWihtoutTime = OffsetDateTime.of(ldtWithoutTime, odtWithTime.getOffset());
  10. // odtWihtoutTime: 2011-02-14T00:00-08:00
  11. // All time information are reset to Zero

代码示例来源:origin: platonai/pulsar

  1. public static boolean isDaysBefore(OffsetDateTime dateTime, int days) {
  2. if (dateTime != null) {
  3. // ZonedDateTime ldt = date.atZone(ZoneId.systemDefault());
  4. if (CURRENT_DATE_EPOCH_DAYS - dateTime.toLocalDate().toEpochDay() > days) {
  5. return true;
  6. }
  7. }
  8. return false;
  9. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * Gets the inclusive temporal start date of this period of time.
  3. *
  4. * If the period is in days, then the returned temporal is a {@link LocalDate} which represents
  5. * the first day of the period.<br>
  6. * Otherwise, the date and the time in UTC/Greenwich at which this period starts on the
  7. * timeline is returned.
  8. * @return a temporal instance ({@link LocalDate} if all day period or {@link OffsetDateTime})
  9. * otherwise.
  10. */
  11. public Temporal getStartDate() {
  12. return isInDays() ? startDateTime.toLocalDate() : startDateTime;
  13. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * Gets the end date of the recurrence. The end date of the recurrence can be unspecified, in that
  3. * case the returned end date is empty.
  4. * @return an optional recurrence end date. The optional is empty if the end date of the
  5. * recurrence is unspecified, otherwise the recurrence termination date or datetime can be get
  6. * from the {@link Optional}. The returned datetime is from UTC/Greenwich.
  7. */
  8. public Optional<Temporal> getRecurrenceEndDate() {
  9. if (this.endDateTime != NO_RECURRENCE_END_DATE) {
  10. return Optional.of(
  11. getStartDate() instanceof LocalDate ? this.endDateTime.toLocalDate() : this.endDateTime);
  12. }
  13. return Optional.empty();
  14. }

代码示例来源:origin: Silverpeas/Silverpeas-Core

  1. /**
  2. * Gets the exclusive temporal end date of this period of time.
  3. *
  4. * If the period is in days, then the returned temporal is a {@link LocalDate} which represents
  5. * the last day of the period.<br>
  6. * Otherwise, the date and the time in UTC/Greenwich at which this period ends on the
  7. * timeline is returned.
  8. * @return a temporal instance ({@link LocalDate} if all day period or {@link OffsetDateTime})
  9. * otherwise.
  10. */
  11. public Temporal getEndDate() {
  12. return isInDays() ? endDateTime.toLocalDate() : endDateTime;
  13. }

代码示例来源:origin: com.bazaarvoice.emodb/emodb-sor

  1. /**
  2. *
  3. */
  4. @Override
  5. protected Scheduler scheduler() {
  6. OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
  7. return Scheduler.newFixedRateSchedule(
  8. Duration.between(now, OffsetDateTime.of(now.toLocalDate().plusDays(1).atStartOfDay(), ZoneOffset.UTC)).getSeconds(),
  9. Duration.ofDays(1).getSeconds(), TimeUnit.SECONDS);
  10. }
  11. }

代码示例来源:origin: com.github.robozonky/robozonky-app

  1. private static List<Development> getDevelopments(final Tenant auth, final int loanId,
  2. final LocalDate delinquentSince) {
  3. final LocalDate lastNonDelinquentDay = delinquentSince.minusDays(1);
  4. final List<Development> developments = auth.call(z -> z.getDevelopments(loanId))
  5. .filter(d -> d.getDateFrom().toLocalDate().isAfter(lastNonDelinquentDay))
  6. .collect(toList());
  7. Collections.reverse(developments);
  8. return developments;
  9. }

代码示例来源:origin: RoboZonky/robozonky

  1. private static List<Development> getDevelopments(final Tenant auth, final int loanId,
  2. final LocalDate delinquentSince) {
  3. final LocalDate lastNonDelinquentDay = delinquentSince.minusDays(1);
  4. final List<Development> developments = auth.call(z -> z.getDevelopments(loanId))
  5. .filter(d -> d.getDateFrom().toLocalDate().isAfter(lastNonDelinquentDay))
  6. .collect(toList());
  7. Collections.reverse(developments);
  8. return developments;
  9. }

代码示例来源:origin: bazaarvoice/emodb

  1. /**
  2. *
  3. */
  4. @Override
  5. protected Scheduler scheduler() {
  6. OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC);
  7. return Scheduler.newFixedRateSchedule(
  8. Duration.between(now, OffsetDateTime.of(now.toLocalDate().plusDays(1).atStartOfDay(), ZoneOffset.UTC)).getSeconds(),
  9. Duration.ofDays(1).getSeconds(), TimeUnit.SECONDS);
  10. }
  11. }

代码示例来源:origin: oracle/pgql-lang

  1. protected static String printLiteral(OffsetDateTime val) {
  2. return "TIMESTAMP '" + val.toLocalDate() + " " + printTime(val.toLocalTime()) + val.getOffset() + "'";
  3. }
  4. }

代码示例来源:origin: com.esotericsoftware/kryo

  1. public void write (Kryo kryo, Output out, OffsetDateTime obj) {
  2. LocalDateSerializer.write(out, obj.toLocalDate());
  3. LocalTimeSerializer.write(out, obj.toLocalTime());
  4. ZoneOffsetSerializer.write(out, obj.getOffset());
  5. }

代码示例来源:origin: com.esotericsoftware/kryo-shaded

  1. public void write (Kryo kryo, Output out, OffsetDateTime obj) {
  2. LocalDateSerializer.write(out, obj.toLocalDate());
  3. LocalTimeSerializer.write(out, obj.toLocalTime());
  4. ZoneOffsetSerializer.write(out, obj.getOffset());
  5. }

代码示例来源:origin: pl.touk.esp/esp-process

  1. public void write(Kryo kryo, Output out, OffsetDateTime obj) {
  2. LocalDateSerializer.write(out, obj.toLocalDate());
  3. LocalTimeSerializer.write(out, obj.toLocalTime());
  4. ZoneOffsetSerializer.write(out, obj.getOffset());
  5. }

代码示例来源:origin: Netflix/iceberg

  1. @Override
  2. @SuppressWarnings("unchecked")
  3. public <T> Literal<T> to(Type type) {
  4. switch (type.typeId()) {
  5. case TIMESTAMP:
  6. return (Literal<T>) this;
  7. case DATE:
  8. return (Literal<T>) new DateLiteral((int) ChronoUnit.DAYS.between(
  9. EPOCH_DAY, EPOCH.plus(value(), ChronoUnit.MICROS).toLocalDate()));
  10. default:
  11. }
  12. return null;
  13. }
  14. }

相关文章