org.joda.time.DateTime.withEarlierOffsetAtOverlap()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(116)

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

DateTime.withEarlierOffsetAtOverlap介绍

[英]Returns a copy of this ZonedDateTime changing the zone offset to the earlier of the two valid offsets at a local time-line overlap.

This method only has any effect when the local time-line overlaps, such as at an autumn daylight savings cutover. In this scenario, there are two valid offsets for the local date-time. Calling this method will return a date-time with the earlier of the two selected.

If this method is called when it is not an overlap, this is returned.

This instance is immutable and unaffected by this method call.
[中]返回此ZonedDateTime的副本,将分区偏移更改为本地时间线重叠处两个有效偏移中的较早者。
此方法仅在本地时间线重叠时有效,例如在秋季夏令时切换时。在这种情况下,本地日期时间有两个有效的偏移量。调用此方法将返回一个日期时间,并选择两者中较早的一个。
如果在该方法不是重叠时调用该方法,则返回该方法。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: JodaOrg/joda-time

/**
 * Converts this LocalDate to a full datetime at the earliest valid time
 * for the date using the specified time zone.
 * <p>
 * The time will normally be midnight, as that is the earliest time on
 * any given day. However, in some time zones when Daylight Savings Time
 * starts, there is no midnight because time jumps from 11:59 to 01:00.
 * This method handles that situation by returning 01:00 on that date.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param zone  the zone to use, null means default zone
 * @return this date as a datetime at the start of the day
 * @since 1.5
 */
public DateTime toDateTimeAtStartOfDay(DateTimeZone zone) {
  zone = DateTimeUtils.getZone(zone);
  Chronology chrono = getChronology().withZone(zone);
  long localMillis = getLocalMillis() + 6L * DateTimeConstants.MILLIS_PER_HOUR;
  long instant = zone.convertLocalToUTC(localMillis, false);
  instant = chrono.dayOfMonth().roundFloor(instant);
  return new DateTime(instant, chrono).withEarlierOffsetAtOverlap();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

final DateTime beforeDstBoundary = dt.withEarlierOffsetAtOverlap();
final DateTime afterDstBoundary = dt.withLaterOffsetAtOverlap();

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

final DateTime beforeDstBoundary = dt.withEarlierOffsetAtOverlap();
final DateTime afterDstBoundary = dt.withLaterOffsetAtOverlap();

相关文章

DateTime类方法