本文整理汇总了Java中java.time.temporal.TemporalQuery类的典型用法代码示例。如果您正苦于以下问题:Java TemporalQuery类的具体用法?Java TemporalQuery怎么用?Java TemporalQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemporalQuery类属于java.time.temporal包,在下文中一共展示了TemporalQuery类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toDateObject
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
private <T> T toDateObject(String raw, TemporalQuery<T> from) {
if (raw.contains(":59:60")) {
// ISO_INSTANT doesn't crash on leap seconds
TemporalAccessor parse = DateTimeFormatter.ISO_INSTANT.parse(raw);
if (parse.query(DateTimeFormatter.parsedLeapSecond())) {
// lazy: push back the second instead
logger.warn("Exciting! Saw a leap second, shifting the date back 1s, {}", raw);
return ISO.parse(raw.replace(":59:60", ":59:59"), from);
}
}
return ISO.parse(raw, from);
}
开发者ID:dehora,项目名称:outland,代码行数:13,代码来源:OffsetDateTimeSerdes.java
示例2: getValue
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/**
* Gets a value using a query.
*
* @param query the query to use, not null
* @return the result, null if not found and optional is true
* @throws DateTimeException if the type is not available and the section is not optional
*/
<R> R getValue(TemporalQuery<R> query) {
R result = temporal.query(query);
if (result == null && optional == 0) {
throw new DateTimeException("Unable to extract value: " + temporal.getClass());
}
return result;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DateTimePrintContext.java
示例3: basicTest_query
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test
public void basicTest_query() {
for (TemporalAccessor sample : samples()) {
assertEquals(sample.query(new TemporalQuery<String>() {
@Override
public String queryFrom(TemporalAccessor temporal) {
return "foo";
}
}), "foo");
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:AbstractDateTimeTest.java
示例4: getValue
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/**
* Gets a value using a query.
*
* @param query the query to use, not null
* @return the result, null if not found and optional is true
* @throws DateTimeException if the type is not available and the section is not optional
*/
<R> R getValue(TemporalQuery<R> query) {
R result = temporal.query(query);
if (result == null && optional == 0) {
throw new DateTimeException("Unable to extract " +
query + " from temporal " + temporal);
}
return result;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DateTimePrintContext.java
示例5: ClassicFormat
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/** Constructor. */
public ClassicFormat(DateTimeFormatter formatter, TemporalQuery<?> parseType) {
this.formatter = formatter;
this.parseType = parseType;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:DateTimeFormatter.java
示例6: ZoneIdPrinterParser
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
ZoneIdPrinterParser(TemporalQuery<ZoneId> query, String description) {
this.query = query;
this.description = description;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:DateTimeFormatterBuilder.java
示例7: test_query
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(dataProvider="query")
public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
assertEquals(temporal.query(query), expected);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKYearMonth.java
示例8: test_queryFrom
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(dataProvider="query")
public <T> void test_queryFrom(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
assertEquals(query.queryFrom(temporal), expected);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:TCKYearMonth.java
示例9: test_parse_Query_String_nullRule
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_parse_Query_String_nullRule() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parse("30", (TemporalQuery<?>) null);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDateTimeFormatter.java
示例10: test_parseBest_String_nullRules
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_parseBest_String_nullRules() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parseBest("30", (TemporalQuery<?>[]) null);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDateTimeFormatter.java
示例11: test_parseBest_String_zeroRules
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_parseBest_String_zeroRules() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parseBest("30", new TemporalQuery<?>[0]);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDateTimeFormatter.java
注:本文中的java.time.temporal.TemporalQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论