本文整理了Java中java.time.LocalDateTime.range()
方法的一些代码示例,展示了LocalDateTime.range()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.range()
方法的具体详情如下:
包路径:java.time.LocalDateTime
类名称:LocalDateTime
方法名:range
[英]Gets the range of valid values for the specified field.
The range object expresses the minimum and maximum valid values for a field. This date-time is used to enhance the accuracy of the returned range. If it is not possible to return the range, because the field is not supported or for some other reason, an exception is thrown.
If the field is a ChronoField then the query is implemented here. The #isSupported(TemporalField) will return appropriate range instances. All other ChronoField instances will throw a DateTimeException.
If the field is not a ChronoField, then the result of this method is obtained by invoking TemporalField.rangeRefinedBy(TemporalAccessor)passing this as the argument. Whether the range can be obtained is determined by the field.
[中]获取指定字段的有效值的范围。
range对象表示字段的最小和最大有效值。此日期时间用于提高返回范围的准确性。如果由于字段不受支持或其他原因而无法返回范围,则会引发异常。
如果该字段是一个ChronoField,则在此处实现查询。#isSupported(临时字段)将返回适当的范围实例。所有其他ChronoField实例将引发DateTimeException。
如果字段不是ChronoField,则通过调用TemporalField获得此方法的结果。rangeRefinedBy(临时Accessor)将此作为参数传递。是否可以获得范围取决于字段。
代码示例来源:origin: com.github.seratch/java-time-backport
return field.range();
return dateTime.range(field);
代码示例来源:origin: com.github.seratch/java-time-backport
return field.range();
return dateTime.range(field);
代码示例来源:origin: espertechinc/esper
public LocalDateTime evaluate(LocalDateTime ldt, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
ValueRange range = ldt.range(fieldName.getChronoField());
return ldt.with(fieldName.getChronoField(), range.getMinimum());
}
代码示例来源:origin: espertechinc/esper
public LocalDateTime evaluate(LocalDateTime ldt, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
ValueRange range = ldt.range(fieldName.getChronoField());
return ldt.with(fieldName.getChronoField(), range.getMaximum());
}
代码示例来源:origin: com.healthmarketscience.jackcess/jackcess
private static int getDayDiff(LocalDateTime ldt1, LocalDateTime ldt2) {
int y1 = ldt1.getYear();
int d1 = ldt1.getDayOfYear();
int y2 = ldt2.getYear();
int d2 = ldt2.getDayOfYear();
while(y2 > y1) {
ldt2 = ldt2.minusYears(1);
d2 += ldt2.range(ChronoField.DAY_OF_YEAR).getMaximum();
y2 = ldt2.getYear();
}
return d2 - d1;
}
内容来源于网络,如有侵权,请联系作者删除!