本文整理了Java中java.time.ZonedDateTime.withDayOfYear()
方法的一些代码示例,展示了ZonedDateTime.withDayOfYear()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.withDayOfYear()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:withDayOfYear
[英]Returns a copy of this ZonedDateTime with the day-of-year altered.
This operates on the local time-line, LocalDateTime#withDayOfYear(int) of the local date-time. This is then converted back to a ZonedDateTime, using the zone ID to obtain the offset.
When converting back to ZonedDateTime, if the local date-time is in an overlap, then the offset will be retained if possible, otherwise the earlier offset will be used. If in a gap, the local date-time will be adjusted forward by the length of the gap.
This instance is immutable and unaffected by this method call.
[中]返回此ZoneDateTime的副本,并更改日期。
这是在本地日期时间的本地时间线LocalDateTime#withDayOfYear(int)上运行的。然后将其转换回ZoneDateTime,使用分区ID获取偏移量。
当转换回ZoneDateTime时,如果本地日期时间重叠,那么如果可能,将保留偏移量,否则将使用较早的偏移量。如果存在间隙,本地日期时间将根据间隙的长度向前调整。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: embulk/embulk
thisSecondOfMinute,
(this.nanoOfSecond == Integer.MIN_VALUE ? 0 : this.nanoOfSecond),
zoneId).withDayOfYear(this.dayOfYear).plusDays(daysRollover);
} else {
代码示例来源:origin: wildfly/wildfly
case YEAR:
zonedDateTime = zonedDateTime.truncatedTo(ChronoUnit.DAYS)
.withDayOfYear(1)
.plus(1, ChronoUnit.YEARS);
break;
代码示例来源:origin: org.elasticsearch/elasticsearch
public ZonedDateTime withDayOfYear(int value) {
return dt.withDayOfYear(value);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
public ZonedDateTime withDayOfYear(int value) {
return dt.withDayOfYear(value);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
case 'y':
if (round) {
dateTime = dateTime.withDayOfYear(1).with(LocalTime.MIN);
} else {
dateTime = dateTime.plusYears(sign * num);
代码示例来源:origin: apache/servicemix-bundles
public ZonedDateTime withDayOfYear(int value) {
return dt.withDayOfYear(value);
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
private static Object convertOutput(Context context, Type type, ZonedDateTime dateTime, Class<?> targetClass, Calendar targetCalendar) throws ConversionException {
if (targetClass == OffsetDateTime.class) {
return dateTime.toOffsetDateTime();
}
if (targetClass == String.class) {
return context.getTimestampFormat().getPrinter().format(dateTime);
}
ZoneId targetZoneId = targetCalendar.getTimeZone().toZoneId();
ZonedDateTime zonedDateTime = dateTime.withZoneSameInstant(targetZoneId);
if (targetClass == Time.class) {
return new Time(zonedDateTime.withYear(1970).withDayOfYear(1).toInstant().toEpochMilli());
}
if (targetClass == Date.class) {
return new Date(zonedDateTime.truncatedTo(ChronoUnit.DAYS).toInstant().toEpochMilli());
}
if (targetClass == Timestamp.class) {
return Timestamp.from(zonedDateTime.toInstant());
}
throw new ConversionException(type, targetClass);
}
代码示例来源:origin: com.impossibl.pgjdbc-ng/pgjdbc-ng
private static Object convertOutput(Context context, Type type, LocalDateTime dateTime, Class<?> targetClass, Calendar targetCalendar) throws ConversionException {
if (targetClass == LocalDateTime.class) {
return dateTime;
}
if (targetClass == LocalDate.class) {
return dateTime.toLocalDate();
}
if (targetClass == String.class) {
return context.getTimestampFormat().getPrinter().format(dateTime);
}
ZoneId targetZoneId = targetCalendar.getTimeZone().toZoneId();
ZonedDateTime zonedDateTime = dateTime.atOffset(ZoneOffset.UTC).atZoneSimilarLocal(targetZoneId);
if (targetClass == Time.class) {
return new Time(zonedDateTime.withYear(1970).withDayOfYear(1).toInstant().toEpochMilli());
}
if (targetClass == Date.class) {
return new Date(zonedDateTime.truncatedTo(ChronoUnit.DAYS).toInstant().toEpochMilli());
}
if (targetClass == Timestamp.class) {
return Timestamp.from(zonedDateTime.toInstant());
}
throw new ConversionException(type, targetClass);
}
代码示例来源:origin: org.apache.james/apache-james-mailbox-elasticsearch
public static ZonedDateTime computeLowerDate(ZonedDateTime date, SearchQuery.DateResolution resolution) {
switch (resolution) {
case Year:
return date.truncatedTo(ChronoUnit.DAYS).withDayOfYear(1);
case Month:
return date.truncatedTo(ChronoUnit.DAYS).withDayOfMonth(1);
default:
return date.truncatedTo(convertDateResolutionField(resolution));
}
}
代码示例来源:origin: org.wildfly.security/wildfly-elytron
case YEAR:
zonedDateTime = zonedDateTime.truncatedTo(ChronoUnit.DAYS)
.withDayOfYear(1)
.plus(1, ChronoUnit.YEARS);
break;
代码示例来源:origin: org.jboss.eap/wildfly-client-all
case YEAR:
zonedDateTime = zonedDateTime.truncatedTo(ChronoUnit.DAYS)
.withDayOfYear(1)
.plus(1, ChronoUnit.YEARS);
break;
代码示例来源:origin: org.wildfly.security/wildfly-elytron-audit
case YEAR:
zonedDateTime = zonedDateTime.truncatedTo(ChronoUnit.DAYS)
.withDayOfYear(1)
.plus(1, ChronoUnit.YEARS);
break;
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
case 'y':
if (round) {
dateTime = dateTime.withDayOfYear(1).with(LocalTime.MIN);
} else {
dateTime = dateTime.plusYears(sign * num);
代码示例来源:origin: apache/servicemix-bundles
case 'y':
if (round) {
dateTime = dateTime.withDayOfYear(1).with(LocalTime.MIN);
} else {
dateTime = dateTime.plusYears(sign * num);
内容来源于网络,如有侵权,请联系作者删除!