org.threeten.bp.OffsetDateTime.toEpochSecond()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(198)

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

OffsetDateTime.toEpochSecond介绍

[英]Converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z.

This allows this date-time to be converted to a value of the ChronoField#INSTANT_SECONDS field. This is primarily intended for low-level conversions rather than general application usage.
[中]将此日期时间转换为从1970-01-01T00:00:00Z开始的秒数。
这允许将此日期时间转换为ChronoField#INSTANT_SECONDS字段的值。这主要用于低级别转换,而不是一般的应用程序使用。

代码示例

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
  public long applyAsLong(OffsetDateTime dt) {
    return dt.toEpochSecond();
  }
},

代码示例来源:origin: ThreeTen/threetenbp

@Override
  public int compare(OffsetDateTime datetime1, OffsetDateTime datetime2) {
    int cmp = Jdk8Methods.compareLongs(datetime1.toEpochSecond(), datetime2.toEpochSecond());
    if (cmp == 0) {
      cmp = Jdk8Methods.compareLongs(datetime1.getNano(), datetime2.getNano());
    }
    return cmp;
  }
};

代码示例来源:origin: org.threeten/threetenbp

@Override
  public int compare(OffsetDateTime datetime1, OffsetDateTime datetime2) {
    int cmp = Jdk8Methods.compareLongs(datetime1.toEpochSecond(), datetime2.toEpochSecond());
    if (cmp == 0) {
      cmp = Jdk8Methods.compareLongs(datetime1.getNano(), datetime2.getNano());
    }
    return cmp;
  }
};

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Checks if the instant of this date-time is equal to that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} and {@link #equals}
 * in that it only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if the instant equals the instant of the specified date-time
 */
public boolean isEqual(OffsetDateTime other) {
  return toEpochSecond() == other.toEpochSecond() &&
      toLocalTime().getNano() == other.toLocalTime().getNano();
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Checks if the instant of this date-time is equal to that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} and {@link #equals}
 * in that it only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if the instant equals the instant of the specified date-time
 */
public boolean isEqual(OffsetDateTime other) {
  return toEpochSecond() == other.toEpochSecond() &&
      toLocalTime().getNano() == other.toLocalTime().getNano();
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Checks if the instant of this date-time is after that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} and {@link #equals} in that it
 * only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if this is after the instant of the specified date-time
 */
public boolean isAfter(OffsetDateTime other) {
  long thisEpochSec = toEpochSecond();
  long otherEpochSec = other.toEpochSecond();
  return thisEpochSec > otherEpochSec ||
    (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano());
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Checks if the instant of this date-time is before that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} in that it
 * only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().isBefore(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if this is before the instant of the specified date-time
 */
public boolean isBefore(OffsetDateTime other) {
  long thisEpochSec = toEpochSecond();
  long otherEpochSec = other.toEpochSecond();
  return thisEpochSec < otherEpochSec ||
    (thisEpochSec == otherEpochSec && toLocalTime().getNano() < other.toLocalTime().getNano());
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Checks if the instant of this date-time is after that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} and {@link #equals} in that it
 * only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if this is after the instant of the specified date-time
 */
public boolean isAfter(OffsetDateTime other) {
  long thisEpochSec = toEpochSecond();
  long otherEpochSec = other.toEpochSecond();
  return thisEpochSec > otherEpochSec ||
    (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano());
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Checks if the instant of this date-time is before that of the specified date-time.
 * <p>
 * This method differs from the comparison in {@link #compareTo} in that it
 * only compares the instant of the date-time. This is equivalent to using
 * {@code dateTime1.toInstant().isBefore(dateTime2.toInstant());}.
 *
 * @param other  the other date-time to compare to, not null
 * @return true if this is before the instant of the specified date-time
 */
public boolean isBefore(OffsetDateTime other) {
  long thisEpochSec = toEpochSecond();
  long otherEpochSec = other.toEpochSecond();
  return thisEpochSec < otherEpochSec ||
    (thisEpochSec == otherEpochSec && toLocalTime().getNano() < other.toLocalTime().getNano());
}

代码示例来源:origin: ThreeTen/threetenbp

if (field instanceof ChronoField) {
  switch ((ChronoField) field) {
    case INSTANT_SECONDS: return toEpochSecond();
    case OFFSET_SECONDS: return getOffset().getTotalSeconds();

代码示例来源:origin: org.threeten/threetenbp

if (field instanceof ChronoField) {
  switch ((ChronoField) field) {
    case INSTANT_SECONDS: return toEpochSecond();
    case OFFSET_SECONDS: return getOffset().getTotalSeconds();

代码示例来源:origin: ThreeTen/threetenbp

return toLocalDateTime().compareTo(other.toLocalDateTime());
int cmp = Jdk8Methods.compareLongs(toEpochSecond(), other.toEpochSecond());
if (cmp == 0) {
  cmp = toLocalTime().getNano() - other.toLocalTime().getNano();

代码示例来源:origin: org.threeten/threetenbp

return toLocalDateTime().compareTo(other.toLocalDateTime());
int cmp = Jdk8Methods.compareLongs(toEpochSecond(), other.toEpochSecond());
if (cmp == 0) {
  cmp = toLocalTime().getNano() - other.toLocalTime().getNano();

相关文章