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

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

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

OffsetDateTime.toOffsetTime介绍

[英]Converts this date-time to an OffsetTime.

This returns an offset time with the same local time and offset.
[中]将此日期时间转换为下班时间。
这将返回具有相同本地时间和偏移量的偏移时间。

代码示例

代码示例来源:origin: DozerMapper/dozer

@Override
public Object convert(Class destClass, Object srcObject) {
  OffsetDateTime offsetDateTime = convertToOffsetDateTime(srcObject);
  if (offsetDateTime != null) {
    if (OffsetTime.class.isAssignableFrom(destClass)) {
      return offsetDateTime.toOffsetTime();
    }
    return offsetDateTime;
  }
  return super.convert(destClass, srcObject);
}

代码示例来源:origin: debezium/debezium

/**
 * Get the ISO 8601 formatted representation of the given {@link OffsetDateTime}.
 * 
 * @param timestamp the timestamp value; may not be null
 * @param adjuster the optional component that adjusts the local date value before obtaining the epoch day; may be null if no
 * adjustment is necessary
 * @return the ISO 8601 formatted string
 */
public static String toIsoString(OffsetDateTime timestamp, TemporalAdjuster adjuster) {
  if (adjuster != null) {
    timestamp = timestamp.with(adjuster);
  }
  return timestamp.toOffsetTime().format(FORMATTER);
}
/**

代码示例来源:origin: org.simpleflatmapper/sfm-converter

@Override
  public OffsetTime convert(Date in, Context context) throws Exception {
    if (in == null) return null;
    return in.toInstant().atZone(dateTimeZone).toOffsetDateTime().toOffsetTime();
  }
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

public OffsetTime time(LocalDate from) {
  if (from == null) {
    return null;
  }
  return from.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

public OffsetTime time(LocalDate from) {
  if (from == null) {
    return null;
  }
  return from.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(LocalDate from) {

代码示例来源:origin: goldmansachs/jdmn

public OffsetTime time(LocalDate from) {
  if (from == null) {
    return null;
  }
  return from.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: goldmansachs/jdmn

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(LocalDate from) {

代码示例来源:origin: goldmansachs/jdmn

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: goldmansachs/jdmn

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(LocalDate from) {

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public OffsetTime convert(Date in, Context context) throws Exception {
    if (in == null) return null;
    return in.toInstant().atZone(dateTimeZone).toOffsetDateTime().toOffsetTime();
  }
}

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

@Override
public OffsetTime fromNonNullValue(Time value) {
  
  return Instant.ofEpochMilli(value.getTime()).atOffset(javaZone).toOffsetTime();
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

@Override
public OffsetTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  return from.toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(LocalDate from) {

代码示例来源:origin: goldmansachs/jdmn

public OffsetTime time(LocalDate from) {
  if (from == null) {
    return null;
  }
  return from.atStartOfDay(ZoneOffset.UTC).toOffsetDateTime().toOffsetTime();
}
public OffsetTime time(OffsetTime from) {

代码示例来源:origin: com.github.dozermapper/dozer-core

@Override
public Object convert(Class destClass, Object srcObject) {
  OffsetDateTime offsetDateTime = convertToOffsetDateTime(srcObject);
  if (offsetDateTime != null) {
    if (OffsetTime.class.isAssignableFrom(destClass)) {
      return offsetDateTime.toOffsetTime();
    }
    return offsetDateTime;
  }
  return super.convert(destClass, srcObject);
}

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

@Override
  public OffsetTime fromNonNullValue(Time value) {

    ZoneOffset currentDatabaseZone = databaseZone == null ? getDefault() : databaseZone;
    
//        int adjustment = TimeZone.getDefault().getOffset(value.getTime()) - (currentDatabaseZone.getRules().getOffset(LocalDateTime.now()).getTotalSeconds() * MILLIS_IN_SECOND);
    
    OffsetDateTime dateTime = Instant.ofEpochMilli(value.getTime()).atOffset(currentDatabaseZone);
    return dateTime.toOffsetTime().withOffsetSameInstant(javaZone);
  }

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

@Override
public OffsetTime fromNonNullValue(Timestamp value) {
  ZoneId currentJavaZone = javaZone == null ? getDefaultZoneId() : javaZone;
  ZonedDateTime zonedDateTime = value.toInstant().with(ChronoField.NANO_OF_SECOND, value.getNanos()).atZone(currentJavaZone);
  OffsetDateTime dateTime = zonedDateTime.toOffsetDateTime();
  
  OffsetTime time = dateTime.toOffsetTime();   
  return time;
}

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

@Override
public ZonedDateTime time(ZonedDateTime from) {
  if (from == null) {
    return null;
  }
  OffsetTime offsetTime = from.toOffsetDateTime().toOffsetTime();
  return offsetTime.atDate(LocalDate.MIN).toZonedDateTime();
}

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

@Override
public OffsetTime fromNonNullValue(Timestamp value) {
  
  ZoneId currentDatabaseZone = getDatabaseZone() == null ? getDefaultZoneOffset() : getDatabaseZone();
  ZoneId currentJavaZone = javaZone == null ? getDefaultZoneOffset() : javaZone;
  OffsetDateTime dateTime = OffsetDateTime.ofInstant(Instant.ofEpochMilli(value.getTime()), currentDatabaseZone);
  dateTime = dateTime.with(ChronoField.NANO_OF_SECOND, value.getNanos()).atZoneSameInstant(currentJavaZone).toOffsetDateTime();
  OffsetTime time = dateTime.toOffsetTime();
  return time;
}

相关文章