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

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

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

DateTime.withLaterOffsetAtOverlap介绍

[英]Returns a copy of this ZonedDateTime changing the zone offset to the later 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 later 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: stackoverflow.com

public static boolean isInOverlap(LocalDateTime ldt, DateTimeZone dtz) {
  DateTime dt1 = ldt.toDateTime(dtz).withEarlierOffsetAtOverlap();
  DateTime dt2 = dt1.withLaterOffsetAtOverlap();
  return dt1.getMillis() != dt2.getMillis();
}

public static void test() {
  // CET DST rolls back at 2011-10-30 2:59:59 (+02) to 2011-10-30 2:00:00 (+01)
  final DateTimeZone dtz = DateTimeZone.forID("CET");
  LocalDateTime ldt1 = new LocalDateTime(2011,10,30,1,50,0,0); // not in overlap
  LocalDateTime ldt2 = new LocalDateTime(2011,10,30,2,50,0,0); // in overlap
  System.out.println(ldt1 + " is in overlap? " + isInOverlap(ldt1, dtz)); 
  System.out.println(ldt2 + " is in overlap? " + isInOverlap(ldt2, dtz)); 
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
protected DateTime fromConvertedColumns(Object[] convertedColumns) {
  LocalDateTime datePart = (LocalDateTime) convertedColumns[0];
  DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1];
  DateTime result;
  if (datePart == null) {
    result = null;
  } else {
    result = datePart.toDateTime(offset.getStandardDateTimeZone());
  }
  
  // Handling DST rollover
  if (result != null && offset.getOffsetDateTimeZone() != null &&
      offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) {
    return result.withLaterOffsetAtOverlap();
  }
  return result;
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
protected DateTime fromConvertedColumns(Object[] convertedColumns) {
  LocalDateTime datePart = (LocalDateTime) convertedColumns[0];
  DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1];
  DateTime result;
  if (datePart == null) {
    result = null;
  } else {
    result = datePart.toDateTime(offset.getStandardDateTimeZone());
  }
  
  // Handling DST rollover
  if (result != null && offset.getOffsetDateTimeZone() != null &&
      offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) {
    return result.withLaterOffsetAtOverlap();
  }
  return result;
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
protected DateTime fromConvertedColumns(Object[] convertedColumns) {
  LocalDateTime datePart = (LocalDateTime) convertedColumns[0];
  DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1];
  DateTime result;
  if (datePart == null) {
    result = null;
  } else {
    result = datePart.toDateTime(offset.getStandardDateTimeZone());            
  }
  
  // Handling DST rollover
  if (result != null && offset.getOffsetDateTimeZone() != null &&
      offset.getStandardDateTimeZone().getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) {
    return result.withLaterOffsetAtOverlap();
  }
  return result;
}

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

final DateTime afterDstBoundary = dt.withLaterOffsetAtOverlap();

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

final DateTime afterDstBoundary = dt.withLaterOffsetAtOverlap();

相关文章

DateTime类方法